Pagini recente » Cod sursa (job #407342) | Cod sursa (job #1807122) | Cod sursa (job #1268553) | Cod sursa (job #680671) | Cod sursa (job #503354)
Cod sursa(job #503354)
#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));
gets(buff);
string needle(buff);
gets(buff);
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 << " ";
}
}