Cod sursa(job #2017469)
| Utilizator | Data | 1 septembrie 2017 13:38:06 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
string A, B;
int r[1003];
int main()
{
int i=0, pos=0;
getline(f, A);
getline(f, B);
f.close();
pos=B.find(A, pos);
while(pos!=string::npos)
{
r[i++]=pos;
//pos+=B.find(A[1], pos+1);
pos++;
if(i==1000)break;
pos=B.find(A, pos);
}
g<<i<<'\n';
for(int j=0; j<i; j++)g<<r[j]<<' ';
return 0;
}
