Cod sursa(job #1982513)
| Utilizator | Data | 19 mai 2017 08:41:27 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string s1,s2;
int nr=0;
int last=-1;
vector <int>pos;
int main()
{
ifstream in("strmatch.in");
ofstream out("strmatch.out");
in>>s1>>s2;
int sizee=s1.size();
while((last=s2.find(s1.c_str(),last+1,sizee))!=string::npos)
nr++,pos.push_back(last);
out<<nr<<'\n';
for(int i=0;i<pos.size();i++)
out<<pos[i]<<" ";
return 0;
}
