Cod sursa(job #2721380)

Utilizator DMR6476Erdic Dragos DMR6476 Data 11 martie 2021 19:03:09
Problema Potrivirea sirurilor Scor 14
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define lim  1000000
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
queue <int> sir;
int main()
{
    char n[lim];
    char k[lim];
    fin.getline(k,lim);
    fin.getline(n,lim);
    int i=0;
    int j=0;
    int sch=0;
    while(i<=strlen(n))
    {
        if(n[i]==k[j])
        {
            while(j<=strlen(k) && n[i+j]==k[j])
                ++j;
            if(j==strlen(k))
                {++sch;j=0;
                sir.push(i);}

        }
        ++i;
    }
    fout<<sch;
    while(!sir.empty())
    {
        cout<<sir.front();
        sir.pop();
    }
    return 0;
}