Pagini recente » Cod sursa (job #2804703) | Cod sursa (job #1091883) | Cod sursa (job #2893819) | Cod sursa (job #2816012) | Cod sursa (job #2180141)
#include <fstream>
#include <string>
#include <vector>
int main() {
std::ifstream f("strmatch.in");
std::ofstream g("strmatch.out");
char *temp = (char*)malloc(sizeof(char) * 1000);
f.getline(temp, 1001);
std::string what(temp);
f.getline(temp, 1001);
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();
}