Cod sursa(job #1938335)

Utilizator otto1Palaga Vicentiu-Octavian otto1 Data 24 martie 2017 19:22:18
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.38 kb
#include<fstream>
#include<cstring>
using namespace std;
char A[2000001],B[2000001];
int n,nr,v[2000001];
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int main()
{f.get(A,2000001);
f.get();
f.get(B,2000001);
while(strstr(B,A))
{n+=strstr(B,A)-B;
n++;
v[++nr]=n-1;
strcpy(B,strstr(B,A)+1);
}
g<<nr<<'\n';
for(int i=1;i<=nr;i++)
g<<v[i]<<' ';
return 0;
}