Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int FLsiDublu(Nod *head)
- {
- int n=0;
- Nod *p=head;
- while(p!=NULL)
- ++n,p=p->leg;
- if(n%2)
- return -1;
- else
- {
- p=head;
- int m=n/2;
- Nod *q;
- while(m)
- {
- --m;
- if(m==0)
- q=p;
- p=p->leg;
- }
- int val=q->info;
- q=q->leg;
- m=n/2;
- bool ok=false;
- p=head;
- while(m--)
- {
- if(p->info!=q->info)
- {
- ok=true;
- break;
- }
- p=p->leg,q=q->leg;
- }
- if(ok)
- return -1;
- else
- return val;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement