Cod sursa(job #361584)

Utilizator funkydvdIancu David Traian funkydvd Data 5 noiembrie 2009 22:10:24
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include<fstream>
#include<cstring>
using namespace std;
ifstream f1 ("strmatch.in");
ofstream f2 ("strmatch.out");
char s1[2000001],s2[2000001],*p;
int main()
{
  int i,n,m,nr=0,k=0,sol[1001];
  f1>>s1>>s2;
  n=strlen(s1);
  m=strlen(s2);
  p=strstr(s2,s1);
  while (p && nr<=1000)
  {
     sol[++nr]=p-s2+k;
	 k++;
     strcpy(p,p+1);
     p=strstr(p,s1);
  }
  f2<<nr<<"\n";
  for (i=1; i<=nr; i++) f2<<sol[i]<<" ";
  return 0;
}