Cod sursa(job #879199)

Utilizator Edward2012Eduard Ursinschi Edward2012 Data 15 februarie 2013 08:22:52
Problema Potrivirea sirurilor Scor 18
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include <fstream>
#include <string.h>

using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char A[1000],B[1000],*p;
int v[1000],k,ok,i;
int main()
{f.getline(A,1000);
 f.getline(B,1000);
 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]<<' ';


    return 0;
}