Pagini recente » Cod sursa (job #2781366) | Cod sursa (job #1127084) | Cod sursa (job #1754925) | Cod sursa (job #1353231) | Cod sursa (job #1210768)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int n, t, i, j;
char *a = (char *) malloc (2000005);
char *b = (char *) malloc (2000005);
char *c;
int pos[2000000], cursor = 0;
FILE *in = fopen("strmatch.in", "r");
FILE *out = fopen("strmatch.out", "w");
fscanf(in, "%s", a);
fscanf(in, "%s", b);
c = b;
int count = 0;
while(c = strstr(c, a)) {
count++;
pos[cursor++] = c - b;
c += 1;
}
fprintf(out, "%d\n", count);
int stop = count < 1000 ? count : 1000;
for (i = 0; i < stop; ++i) {
fprintf(out, "%d ", pos[i]);
}
fprintf(out, "\n");
fclose(in);
fclose(out);
return 0;
}