Cod sursa(job #918931)
Utilizator | Data | 19 martie 2013 11:20:26 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include<fstream>
#include<cstring>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char vers[2000000],k,s[2000000];
int nr,l,p,poz[1010],i;
int main()
{
f.get(s,2000000);
f.get();
f.get(vers,2000000);
while(strstr(vers,s)!=0)
{
p=strstr(vers,s)-vers;
strcpy(vers+p,vers+p+1);
nr++;
poz[k]=p+k;
k++;
}
g<<nr<<"\n";
for(i=0;i<k&&i<1000;i++)
g<<poz[i]<<" ";
return 0;
}