Pagini recente » Cod sursa (job #2178460) | Cod sursa (job #2035822) | Cod sursa (job #631613) | Cod sursa (job #3125229) | Cod sursa (job #899701)
Cod sursa(job #899701)
#include <fstream>
#include <string>
using namespace std;
// Solutie folosind find din tipul string
ifstream in("strmatch.in");
ofstream out("strmatch.out");
int pos[1010];
int k;
string A, B;
int main()
{
getline(in, A);
getline(in, B);
unsigned found = 0;
while (found != string::npos)
{
found = B.find(A, found);
if (found != string::npos)
{
k++;
if (k <= 1000) pos[k] = found++;
}
}
out << k << '\n';
int min = k <= 1000 ? k : 1000;
for (int i = 1; i <= min; i++) out << pos[i] << ' ';
return 0;
}