Cod sursa(job #2935255)

Utilizator St4ckyAlex Onita St4cky Data 6 noiembrie 2022 13:25:12
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.8 kb
#include <bits/stdc++.h>
using namespace std;

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

int main()
{
    string word;
    string text;
    fin>>word>>text;
    int poz=0;
    int cnt=0;
    vector <int> v;
    for (int i=0; i<text.size(); i++)
    {
        bool match=true;
        for (int j=0; j<word.size(); j++)
        {
                if (text[poz+j]!=word[j])
                {
                    match=false;
                    break;
                }
        }
        if (match==true)
        {
            cnt++;
            v.push_back(poz);
        }
        poz++;
    }
    fout<<v.size()<<'\n';
    for (int i=0; i<v.size(); i++)
    {
        if (v.size()<1000)
        {
             fout<<v[i]<<" ";
        }
    }
    return 0;
}