Cod sursa(job #1920735)
| Utilizator | Data | 10 martie 2017 09:40:46 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
ifstream f ("strmatch.in");
ofstream t ("strmatch.out");
int main()
{
int counter=0;
vector <int> pos;
string match,pattern;
f>>match>>pattern;
size_t last=pattern.find(match);
for (;last!=string::npos;++counter){
pos.push_back(last);
last=pattern.find(match,last+1);
}
t<<counter<<'\n';
for (auto i:pos)
t<<i<<" ";
return 0;
}
