Cod sursa(job #2675047)
| Utilizator | Data | 21 noiembrie 2020 09:39:45 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <cstdio>
#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);
scanf("%[^\n]", &a);
scanf("\n");
scanf("%[^\n]", &b);
char *p = strstr(b, a);
while (p) {
if (ind < 1000)
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;
}
