Cod sursa(job #2675037)
| Utilizator | Data | 21 noiembrie 2020 09:35:31 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <stdio.h>
#include <cstring>
#include <fstream>
char a[2000005], b[2000005];
int poz[1005], ind;
int main() {
freopen("strmatch.in", "r", stdin);
freopen("strmatch.out", "w", stdout);
gets(a);
gets(b);
char *p = strstr(b, a);
while (p) {
if (ind < 10000)
poz[ind] = p - b;
ind++;
p = strstr(p + 1, a);
}
printf("%d\n", ind);
int stop = ind < 1000 ? ind : 1000;
for (int i = 0; i < stop; ++i)
printf("%d ", poz[i]);
return 0;
}
