Pagini recente » Cod sursa (job #1489411) | Cod sursa (job #851745) | Cod sursa (job #1017814) | Cod sursa (job #136764) | Cod sursa (job #235712)
Cod sursa(job #235712)
#include <fstream>
#include <string.h>
using namespace std;
fstream fin ("strmatch.in",ios::in);
fstream fout("strmatch.out",ios::out);
char a[2000000];
char b[2000000];
int poz[1000];
char *p,*q;
int apar=0;
int cate=0;
int lungA,lungB;
int main(){
fin.getline(b,2000000);
fin.getline(a,2000000);
lungA=strlen(a);
lungB=strlen(b);
p=strstr(a,b);
while (p!=NULL){
apar++;
p=strstr(p,b);
if (cate<1000 && p!=NULL){
poz[cate]=strlen(a)-strlen(p);
cate++;
}
if (p!=NULL)
p=p+1;
}
if (apar!=0)
fout<<apar-1;
else fout<<0;
fout<<endl;
for (int i=0;i<cate;i++)
fout<<poz[i]<<" ";
}