Pagini recente » Cod sursa (job #2374312) | Cod sursa (job #11479) | Cod sursa (job #3188294) | Cod sursa (job #2834035) | Cod sursa (job #1971699)
#include<stdio.h>
#include<string>
#include<fstream>
#include<vector>
using namespace std;
ifstream cin("strmatch.in");
ofstream cout("strmatch.out");
struct result{
int nr;
vector<int> matches;
};
result GetMatches(string a, string b)
{
result res;
res.nr = 0;
long long found = 0;
do{
found = b.find(a, found);
if(found < b.length())
{
++res.nr;
if(res.matches.size() < 1000)
{
res.matches.push_back(found);
}
}
++found;
}while(found < b.length());
return res;
}
int main(){
string a, b;
cin >> a >> b;
result res = GetMatches(a, b);
cout << res.nr << endl;
for(int i = 0; i < res.matches.size(); ++i)
{
cout << res.matches[i] << " ";
}
cin.close();
cout.close();
return 0;
}