Cod sursa(job #1991778)
Utilizator | Aelenei Roxana roxana.aelenei | Data | 18 iunie 2017 13:14:17 |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
#include <cstring>
#include <cmath>
using namespace std;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
string a,b;
int v[1005],cnt;
int main()
{
int poz;
in>>a;
in>>b;
poz=b.find(a);
while(poz >=0)
{
cnt++;
if(cnt < 1001) v[cnt]=poz;
poz=b.find(a,poz+1);
}
out<<cnt<<'\n';
int minn=min(cnt,1000);
for(int i=1; i<=minn; i++)
out<<v[i]<<" ";
return 0;
}