Cod sursa(job #1966955)

Utilizator nicu_serteSerte Nicu nicu_serte Data 15 aprilie 2017 18:43:19
Problema Potrivirea sirurilor Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
int main()
{
    int n=0, found=0;
    string a, b;
    vector<int> poz;
    vector<int>::iterator it;
    fin>>a>>b;
    fin.close();
    do
    {
        found=b.find(a, found);
        if(found>=0)
        {
            n++;
            poz.push_back(found);
        }
        found++;
    }while(found);
    fout<<n<<'\n';
    for(it=poz.begin(), n=0; it!=poz.end() && n<1000; it++, n++)
        fout<<*it<<' ';
    fout<<'\n';
    fout.close();
    return 0;
}