Cod sursa(job #857030)

Utilizator TwistedFaithStanescu Jean Alexandru TwistedFaith Data 17 ianuarie 2013 10:07:45
Problema Potrivirea sirurilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

ifstream fin("strmatch.in");
ofstream fout("strmatch.out");

#define MAX 2000002
char a[MAX],b[MAX],*p;
long int k[MAX],h,i;

int main()
{
    fin.get(a, MAX);
    fin.get();
    fin.get(b, MAX); p=b;
    do
    {
        p=strstr(p, a);
        if (p) {k[h++]=p-b; p++;}

    }
    while(p);
    fout<<h<<'\n';
    for(i=0;i<h;i++) fout<<k[i]<<' ';
}