Cod sursa(job #1966952)
| Utilizator | Data | 15 aprilie 2017 18:40:50 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 78 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
int main()
{
int n=0, found=0;
string a, b;
vector<int> poz;
vector<int>::iterator it;
fin>>a>>b;
fin.close();
do
{
found=b.find(a, found);
if(found>0)
{
n++;
poz.push_back(found);
}
found++;
}while(found>0);
fout<<n<<'\n';
for(it=poz.begin(), n=0; it!=poz.end() && n<1000; it++, n++)
fout<<*it<<' ';
fout<<'\n';
fout.close();
return 0;
}
