Cod sursa(job #1654324)

Utilizator SlevySlevoaca Stefan-Gabriel Slevy Data 16 martie 2016 22:42:48
Problema Potrivirea sirurilor Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <iostream>
#include <fstream>
#include <cstring>
#include <queue>
#define LIM 1000

using namespace std;

ifstream in("strmatch.in");
ofstream out("strmatch.out");
int nr = 0;
queue<int> coada;
string a,b;

int main()
{
    in>>a>>b;
    size_t where = b.find(a);
    while(where != string::npos)
    {
        nr++;
        if(nr<=LIM)
            coada.push((int)where);
        where = b.find(a,where+1);
    }
    out<<nr<<"\n";
    while(!coada.empty())
    {
        out<<coada.front()<<" ";
        coada.pop();
    }
    out.close();
    return 0;
}