Cod sursa(job #2331001)

Utilizator maria.tantosMaria Iuliana Tantos maria.tantos Data 29 ianuarie 2019 08:33:44
Problema Potrivirea sirurilor Scor 18
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.48 kb
#include <bits/stdc++.h>
using namespace std;

ifstream f("strmatch.in");
ofstream g("strmatch.out");
char a[2000001],b[2000001],*p;
int i,nr,poz,sters;

int main()
{
    int potrivire[1001];
    f>>a>>b;int la=strlen(a);
    while(strstr(b,a))
    {
        p=strstr(b,a);
        poz=p-b;
        potrivire[++nr]=poz+sters;
        strcpy(b,b+poz+la);
        sters+=poz+la;
    }
    g<<nr<<'\n';
    for(i=1;i<=nr;i++)
        g<<potrivire[i]<<' ';
    return 0;
}