Pagini recente » Cod sursa (job #2348171) | Cod sursa (job #188758) | Cod sursa (job #1875908) | Cod sursa (job #297306) | Cod sursa (job #2675086)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream f ("strmatch.in");
ofstream g ("strmatch.out");
char A[2000001],B[2000001];
int poz[2000001];
int main()
{
f.getline(A,2000001);
f.getline(B,2000001);
int cnt = 1;
char *p = strstr(B,A);
while(p && cnt<1001)
{
poz[cnt++] = p-B;
p = strstr(p+1,A);
}
g << cnt-1<< '\n';
for(int i = 1;i<min(cnt,1001);i++)
g << poz[i]<< " ";
}