Pagini recente » Cod sursa (job #2885042) | Cod sursa (job #1840795) | Cod sursa (job #2419875) | Cod sursa (job #1207548) | Cod sursa (job #2515997)
#include <fstream>
#include <iostream>
#include <cstring>
using namespace std;
#define dmax 2000001
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
int main(){
char a[dmax], b[dmax];
unsigned v[1001], n=0;
fin.get(a, dmax);
fin.get();
fin.get(b, dmax);
char *p;
p=b;
unsigned k=0;
do{
p=strstr(p, a);
if (p){
++k;
if (n<1000)
v[++n]=p-b;
p=p+1;
}
}while (p);
cout<<k<<endl;
for (int i=1;i<=n;i++)
cout<<v[i]<<" ";
fin.close();
fout.close();
}