Cod sursa(job #879201)

Utilizator Edward2012Eduard Ursinschi Edward2012 Data 15 februarie 2013 08:24:59
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include <fstream>
#include <string.h>

using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char A[2000000],B[2000000],*p;
int v[2000000],k,ok,i;
int main()
{f.getline(A,2000000);
 f.getline(B,2000000);
 while(ok==0)
 {ok=1;
  if(strstr(B,A)) {p=strstr(B,A);ok=0;v[++k]=strlen(B)-strlen(p);p[0]='-';}
 }
 g<<k<<'\n';
 for(i=1;i<=k;i++) g<<v[i]<<' ';
 g<<'\n';


    return 0;
}