Pagini recente » Cod sursa (job #156646) | Cod sursa (job #2197296) | Cod sursa (job #2377678) | Cod sursa (job #2786276) | Cod sursa (job #2335409)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int main()
{
char *p;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char c[2000000];
f>>c;
int m;
m=strlen(c);
char b[m+5];
strcpy(b,c);
f>>c;
int n;
n=strlen(c);
char a[n+3];
strcpy(a,c);
int pot[1001];
int i;
i=0;
pot[-1]=-1;
while(strstr(a,b)!=NULL){
p=strstr(a,b);
pot[i]=p-a+pot[i-1]+1;
i++;
if(i==1000)break;
strcpy(a,p+1);
}
g<<i<<endl;
for(int j=0;j<i;j++)g<< pot[j]<<" ";
}