Cod sursa(job #2596097)

Utilizator k2e0e0w3qDumitrescu Gheorghe k2e0e0w3q Data 9 aprilie 2020 11:36:39
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <stdio.h>
#include <string.h>
#define N 2000001

char s[N], t[N], *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;
        if (ct<1001)
            fprintf (fout, "%d ", pch-s);
        pch=strstr(pch+1, t);
    }
    fseek(fout, 0, SEEK_SET);
    fprintf (fout, "%d", ct);
    return 0;
}