Pagini recente » Cod sursa (job #636136) | Istoria paginii preoni-2008/clasament/runda-3/9 | Cod sursa (job #1370891) | Cod sursa (job #2990107) | Cod sursa (job #1232153)
#include <fstream>
#define MAX_MATCHES 1000
using namespace std;
int POSITIONS[MAX_MATCHES];
int main()
{
ifstream ifs("strmatch.in");
ofstream ofs("strmatch.out");
string A, B;
ifs >> A >> B;
int n_matches = 0;
int i = 0;
while (i <= (B.length() - A.length()))
{
int j = 0;
while (j < A.length() && A[j] == B[i+j]) ++j;
if (j == A.length())
{
if (n_matches < MAX_MATCHES)
POSITIONS[n_matches++] = i;
}
++i;
}
ofs << n_matches << "\n";
for (int i = 0; i < n_matches; ++i)
ofs << POSITIONS[i] << " ";
return 0;
}