Cod sursa(job #2045775)

Utilizator enedumitruene dumitru enedumitru Data 22 octombrie 2017 20:46:50
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("strmatch.in"); ofstream g("strmatch.out");
char a[2000001],b[2000001],*c;
int main()
{
    int n=0,sir,nr;
    int v[1001];
    f>>a>>b;
    sir=strlen(b);
    while(strstr(b,a)!=0&&n<=1000)
    {
        n++;
        c=strstr(b,a);
        nr=strlen(c);
        v[n]=sir-nr;
        strcpy(b,c+1);
    }
    g<<n<<'\n';
    for (int i=1;i<=n;i++) g<<v[i]<<" ";
}