Cod sursa(job #3306234)

Utilizator andiRTanasescu Andrei-Rares andiR Data 8 august 2025 17:15:14
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream f("strmatch.in");

ofstream g("strmatch.out");

int i1,i2,cnt,poz[2000000];

int main()
{
    string a;
    string b;

    f>>a>>b;

    for(i1=0; i1<=(int)b.size()-(int)a.size(); i1++)
    {
        bool ok=0;
        for(i2=0; i2<a.size(); i2++)
        {
            if(b[i1+i2]!=a[i2])
            {
                ok=1;
            }
        }

        if(ok==0)
        {
            cnt++;
            poz[cnt]=i1;
        }
    }

    g<<cnt<<'\n';
    for(int x=1;x<=cnt;x++)
    {
        g<<poz[x]<<' ';
    }
    return 0;
}