Pagini recente » Cod sursa (job #1451142) | Cod sursa (job #1476925) | Cod sursa (job #2047181) | Cod sursa (job #231509) | Cod sursa (job #503353)
Cod sursa(job #503353)
#include <cassert>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MAX_SOL = 1000;
const int MAX_BUF = 2000005;
char buff[MAX_BUF];
int main() {
assert(freopen("strmatch.in", "r", stdin));
assert(freopen("strmatch.out", "w", stdout));
assert(scanf("%s", buff) == 1);
string needle(buff);
assert(scanf("%s", buff) == 1);
string hay(buff);
int no_sol = 0, pos = -1;
vector<int> match;
while ((pos = hay.find(needle, pos + 1)) != string::npos) {
if (++no_sol <= MAX_SOL) {
match.push_back(pos);
}
}
cout << no_sol << "\n";
for (vector<int>::iterator it = match.begin(); it != match.end(); ++it) {
cout << *it << " ";
}
}