Pagini recente » Cod sursa (job #2740453) | Cod sursa (job #2681795) | Cod sursa (job #1424622) | Cod sursa (job #3227286) | Cod sursa (job #501808)
Cod sursa(job #501808)
#include<iostream.h>
#include<fstream.h>
#include<string.h>
int main()
{char a;
int k=1,y=0,ok;
ifstream f("strmatch.in");
ofstream h("strmatch.out");
struct nod{char info;
nod*next;};
nod *c,*p,*u,*c1,*p1,*u1;
p=new nod;
f>>a;
p->info=a;
u=p;
for(int i=1;i<=2;i++)
{f>>a;
c=new nod;
c->info=a;
u->next=c;
u=c;}
u->next=0;
c=p;
f>>a;
p1=new nod;
p1->info=a;
u1=p1;
while(!f.eof())
{c1=new nod;
f>>c1->info;
u1->next=c1;
u1=c1;}
u1->next=0;
c1=p1;
while(c1->next!=0)
{if(c1->info==c->info)
{ok=1;
c1=c1->next;
c=c->next;
while(c1->next!=0||ok==1)
{if(c1->info==c->info)
{c1=c1->next;
c=c->next;
}
else
ok=0;}
if(ok==1)
y++;
}
}cout<<y;
return 0;}