Pagini recente » Cod sursa (job #3265095) | Cod sursa (job #1373739) | Cod sursa (job #2819789) | Cod sursa (job #510871) | Cod sursa (job #1512832)
#include <fstream>
#include <cstring>
#define nmx 2000002
#define nx 1002
using namespace std;
ifstream f("strmatch.in");
ofstream o("strmatch.out");
char a[nmx],b[nmx];
int af[nx],la,lb,pa,pb,st,q;
int main() {
f >> a >> b;
la = strlen(a);
lb = strlen(b);
while(pb < lb) {
q = 0,st = pb;
pa = 0;
while(pa < la) {
if(not q && pa && b[pb] == a[0])
q = pb;
if(a[pa] != b[pb]) {
break;
}
++ pa;
++ pb;
}
if(af[0] < 1000 && pa == la) {
af[++af[0]] = st;
}
if(q)
pb = q;
else
++ pb;
}
o << af[0] << "\n";
for(int i = 1; i <= af[0]; ++i)
o << af[i] << " ";
return 0;
}