Cod sursa(job #1058187)

Utilizator BlackLordFMI Alex Oprea BlackLord Data 15 decembrie 2013 11:05:33
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>
#include <cstring>
#define DIM 2000010
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int n, m, x, v[20000], k, i;
char a[DIM], b[DIM], *p;
int main(){
    f.get(a, DIM);
    f.get();
    f.get(b, DIM);
    p=strstr(b, a);
    while(p)
    {
        k++;
        v[k]=p-b;
        p=strstr(p+1, a);
    }
    g<<k<<"\n";
    for(i=1; i<=k; i++)
        g<<v[i]<<' ';
    g<<"\n";
    return 0;
}