Pagini recente » Cod sursa (job #2594705) | Cod sursa (job #2819584) | Cod sursa (job #2817887) | Cod sursa (job #2923050) | Cod sursa (job #1221007)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
const int MAXDIM = 2000005;
const int MAXPOZ = 1000005;
char a[MAXDIM], b[MAXDIM];
int poz[MAXPOZ], npoz;
int n, m;
int ap;
int main()
{
char *p;
fin.getline( a, MAXDIM ); n = strlen( a );
fin.getline( b, MAXDIM ); m = strlen( b );
// cout << a << '\n' << b; cin.get();
p = strstr( b, a );
while ( p )
{
ap++;
poz[++npoz] = p - b;
// cout << p - b << '\n'; cin.get();
p++; p = strstr( p, a );
}
fout << ap << '\n';
for ( int i = 1; i <= npoz; i++ )
fout << poz[i] << ' ';
fin.close();
fout.close();
return 0;
}