Pagini recente » Cod sursa (job #468512) | Cod sursa (job #2615594) | Cod sursa (job #151101) | Cod sursa (job #2704319) | Cod sursa (job #1228734)
#include<fstream>
#include<iostream>
#include<string>
#include<list>
#define MOD1 99991
#define MOD2 99871
#define B1 10
#define B2 23
using namespace std;
void read(string &A, string &B)
{
ifstream f("strmatch.in");
f>>A>>B;
f.close();
}
void write(const int &nr_sol, const list<int> &sol)
{
ofstream g("strmatch.out");
g<<nr_sol<<"\n";
for(auto it = sol.begin(); it != sol.end(); ++it)
g<<*it<<" ";
g.close();
}
int main()
{
string A, B;
read(A, B);
int found = B.find(A), nr_sol;
list<int> sol;
for(nr_sol = 0; found != string::npos; found = B.find(A, found + 1), ++nr_sol)
{
if(nr_sol < 1000)
sol.push_back(found);
}
write(nr_sol, sol);
return 0;
}