Cod sursa(job #166835)
| Utilizator | Data | 28 martie 2008 15:50:50 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <stdio.h>
#include <string.h>
long num, i, n, poz[2000010], npoz;
char x[2000010], y[2000010];
int main()
{
freopen ("strmatch.in", "rt", stdin);
freopen ("strmatch.out", "wt", stdout);
scanf("%s\n%s", x, y);
n = strlen(y) - 1;
char *p = strstr(y, x);
while (p)
{
num ++;
poz[++npoz] = p - y;
if (num == 1000)
break;
p = strstr(p + 1, x);
}
printf("%ld\n", num);
for (i = 1; i <= npoz; ++i)
printf("%ld ", poz[i]);
printf("\n");
return 0;
}