Pagini recente » Cod sursa (job #3266207) | Cod sursa (job #2375644) | Cod sursa (job #3268819) | Cod sursa (job #2986065) | Cod sursa (job #2909959)
#include <fstream>
#include <cstring>
#define DIM 2000000
using namespace std;
char A[DIM+2], B[DIM+2];
int sol[1001];
int a, b, nr, i;
int main () {
ifstream fin ("strmatch.in");
ofstream fout("strmatch.out");
fin>>A+1>>B+1;
a = strlen(A+1);
b = strlen(B+1);
for (i=a;i<=b;i++) {
int ok = 1;
for (int ia = 1, ib = i-a+1; ia<=a; ia++, ib++) {
if (A[ia] != B[ib]) {
ok = 0;
break;
}
}
if (ok) {
nr++;
if (nr <= 1000)
sol[nr] = i-a;
}
}
fout<<nr<<"\n";
for (i=1;i<=nr;i++)
fout<<sol[i]<<" ";
return 0;
}