Cod sursa(job #2265248)

Utilizator SonnyXDCristi Mamota SonnyXD Data 20 octombrie 2018 21:17:11
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
#define NMax 2000005

using namespace std;

ifstream f("strmatch.in");
ofstream g("strmatch.out");

int main()
{
    int nr=0, v[NMax], k=0;
    int pos=0;
    string a, b;
    f>>a>>b;
    while ((pos = b.find(a, pos)) != string::npos)
    {
        nr++;
        v[k]=pos;
        k++;
        pos++;
    }
    g<<nr<<endl;
    for(int i=0;i<k;i++)
        g<<v[i]<<" ";
    return 0;
}