Cod sursa(job #1337836)
| Utilizator | Data | 9 februarie 2015 16:09:31 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include<iostream>
#include<fstream>
#include<string.h>
#include<vector>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char str1[2000010], str2[2000010];
vector<int> w;
int nr=0 ,k=0 ;
int main()
{
f>>str1;
f>>str2;
int lg1 =strlen(str1);
int lg2 = strlen(str2);
int i ,j;
for(i=0;i<=lg2-lg1;i++){
for(j =0;j<lg1; j++){
if(str2[i+j] != str1[j]) break;
}
if(j==lg1){
w.push_back (i);
nr++;
}
}
g<<nr<<endl;
for(int k=0;k<w.size();k++){
g<<w[k]<<" ";
}
return 0;
}
