Cod sursa(job #1968373)
| Utilizator | Data | 17 aprilie 2017 17:31:54 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream f("strmatch.in");
ofstream g("strmatch.out");
string p, q;
int n = 0, poz[1024];
f >> p >> q;
int found = 0;
do {
found = q.find(p, found);
if (found >= 0) {
n++;
if (n <= 1000) poz[n] = found;
}
found++;
} while (found);
g << n << "\n";
if (n > 1000) n = 1000;
for (int i = 1; i <= n; ++i)
g << poz[i] << " ";
return 0;
}
