Cod sursa(job #1982686)
| Utilizator | Data | 19 mai 2017 21:41:55 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 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<1000;i++)
out<<pos[i]<<" ";
return 0;
}
