Cod sursa(job #2918867)

Utilizator Samoila_AlexandruSamoilaAlexandru Samoila_Alexandru Data 13 august 2022 16:06:23
Problema Potrivirea sirurilor Scor 14
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <cstring>
#define dim 2000005

using namespace std;

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

char a[dim], b[dim];
int v[dim/2], k=0;

int main()
{
    fin>>a>>b;

    fin.close();

    int i=0, j=0, aux=0;

    while(b[i]!='\0')
    {
        aux=i, j=0;

        while(a[j]==b[i])
            j++, i++;

        if(j==strlen(a))
            v[++k]=aux, i=aux;


        i++;
    }

    fout<<k<<'\n';

    for(int i=1; i<=k; i++)
        fout<<v[i]<<' ';

    fout.close();

    return 0;
}