Cod sursa(job #2279853)

Utilizator grecubogdanGrecu Bogdan grecubogdan Data 10 noiembrie 2018 09:39:25
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <fstream>
#include <string.h>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int i,c,a[1002];
char s1[2000000],s2[2000000],*p;
int main()
{
 f.get(s1,2000000);
 f.get();
 f.get(s2,2000000);
 p=strstr(s2,s1);
 while(p)
 {
     c++;
     if(c<=1000)
     a[c]=p-s2;
     p=strstr(p+1,s1);
 }
 g<<c<<'\n';
 for(i=1;i<=c&&i<=1000;i++)
    g<<a[i]<<" ";
 return 0;
}