Cod sursa(job #2595404)

Utilizator k2e0e0w3qDumitrescu Gheorghe k2e0e0w3q Data 7 aprilie 2020 17:48:03
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <stdio.h>
#include <string.h>

char s[2000001], t[2000001], *pch;
int main () {
    freopen ("strmatch.in", "r", stdin);
    FILE *fout=fopen ("strmatch.out", "w");
    gets(t);
    gets(s);
    pch=strstr(s, t);

    fprintf (fout, "        \n");
    int ct=0;
    while (pch && ct<1000) {
        ++ct;
        fprintf (fout, "%d ", pch-s);
        pch=strstr(pch+1, t);
    }
    fseek(fout, 0, SEEK_SET);
    fprintf (fout, "%d", ct);
    return 0;
}