Cod sursa(job #2617276)

Utilizator pro119Manea Dumitru pro119 Data 21 mai 2020 12:47:01
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>
using namespace std;
#define ll long long


string a,b;
int main()
{
    ifstream cin("strmatch.in");
    ofstream cout("strmatch.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b;
    int v[1005]={},k=1;
    int poz = b.find(a);
    if (poz!=-1) v[k++]=poz;
    while(1){
        poz = b.find(a,poz+1);
        if (poz!=-1 && k<=1000) v[k++]=poz;
        else break;
    }

    cout<<k-1<<"\n";
    for (int i=1; i<k; i++)
        cout<<v[i]<<" ";

    return 0;
}