Pagini recente » Cod sursa (job #42466) | Cod sursa (job #1285281) | Cod sursa (job #501845) | Cod sursa (job #736852) | Cod sursa (job #2180144)
#include <fstream>
#include <string>
#include <vector>
int main() {
const std::string file = "strmatch";
std::ifstream f(file + ".in");
std::ofstream g(file + ".out");
char *temp = (char*)malloc(sizeof(char) * 2000005);
f.getline(temp, 200006);
std::string what(temp);
f.getline(temp, 200006);
std::string in(temp);
free(temp);
int nr = 0;
size_t pos = in.find(what, 0);
std::vector<size_t> vpos;
while (pos != std::string::npos) {
vpos.push_back(pos);
nr++;
pos = in.find(what, pos + 1);
}
g << nr << std::endl;
for (auto const& i: vpos) {
g << i << " ";
}
g << std::endl;
f.close();
g.close();
}