Cod sursa(job #1429070)

Utilizator teoceltareconstantin teodor teoceltare Data 5 mai 2015 16:59:01
Problema Potrivirea sirurilor Scor 24
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
std::ifstream fin("strmatch.in");
std::ofstream fout("strmatch.out");
int v[1010];
long long n=0;
std::string a,b;
int main()
{
    fin>>a>>b;
    int x;
    x=b.find(a);
    if(x!=0)
    {
        n++;
        v[n]=x;
        while(x)
        {
            x=b.find(a,x+1);
            if (x == std::string::npos) break;
            else{
            n++;
            if(n<=1001)
            {
                v[n]=x;
            }
            }
        }
    }
    fout<<n<<'\n';
    for(int a=1;a<=n and a<=1001;a++)
    {
        fout<<v[a]<<" ";
    }
}