Pagini recente » Cod sursa (job #1379662) | Cod sursa (job #2907691) | Cod sursa (job #2402081) | Cod sursa (job #2888358) | Cod sursa (job #2662251)
#include <fstream>
#include <cstring>
#define nmax 2000001
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char s[nmax],a[nmax];
int nr,v[1001],cnt;
int main()
{
fin>>a;
fin>>s;
int poz=strstr(s,a)-s;
while (poz>=0)
{
cnt++;
if (cnt<=1000)
v[cnt]=poz;
if (strstr(s+poz+1,a)==NULL)
poz=-1;
else
poz=strstr(s+poz+1,a)-s;
}
fout<<cnt<<'\n';
for (int i=1;i<=cnt;i++)
fout<<v[i]<<' ';
return 0;
}