Pagini recente » Cod sursa (job #2332726) | Cod sursa (job #211952) | Cod sursa (job #2494438) | Cod sursa (job #1624860) | Cod sursa (job #2210932)
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
string A, B;
int numberOfMatches = 0;
vector <int> indexListOfMatches;
void Read(void)
{
fin >> A >> B;
}
void Match(void)
{
int index = 0;
bool match = true;
for (unsigned int i = 0; i < B.size(); i++)
{
if (!B.compare(i, A.size(), A) )
{
numberOfMatches++;
indexListOfMatches.push_back(i);
}
}
}
void Print(void)
{
fout << numberOfMatches << '\n';
int limitIndex;
if (numberOfMatches > 1000)
{
limitIndex = 1000;
}
else
{
limitIndex = numberOfMatches;
}
for (int i = 0; i < limitIndex; i++)
{
fout << indexListOfMatches.at(i) << ' ';
}
}
int main(void)
{
Read();
Match();
Print();
return 0;
}