Pagini recente » Cod sursa (job #2528213) | Cod sursa (job #2955275) | Cod sursa (job #1576100) | Cod sursa (job #2614112) | Cod sursa (job #2107281)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char A[2000005], B[2000005], *p;
int n, x, v[50];
int main()
{
f>>B;
f>>A;
if(B[0]==B[strlen(B)-1]) x=1;
int k=0, q=0;
p=strstr(A, B);
while(p)
{
k++;
n=p-A;
if(q==0) v[++q]=n;
else v[++q]=n+(strlen(B)-x)*(q-1);
strcpy(A+n, A+n+strlen(B)-x);
p=strstr(A, B);
}
g<<k<<endl;
if(q>1000) q=1000;
for(int i=1;i<=q;i++) g<<v[i]<<" ";
return 0;
}