Cod sursa(job #2487989)
| Utilizator | Data | 5 noiembrie 2019 22:26:07 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include<fstream>
#include<iostream>
#define MAX_POS 1000
using namespace std;
int main() {
int found, cnt, v[MAX_POS], len, i;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
string T, P;
fin >> P >> T;
found = T.find(P);
cnt = 0;
len = 0;
while(found != string::npos) {
++cnt;
if(cnt <= MAX_POS)
v[len++] = found;
found = T.find(P, found + 1);
}
fout << cnt << "\n";
for(i = 0; i < len; i++)
fout << v[i] << " ";
fout << "\n";
fin.close();
fout.close();
return 0;
}
