Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct node
- {
- int value;
- struct node *blink;
- struct node *flink;
- };
- int n;
- node a[100];
- node *p=&a[0];
- void input()
- {
- cout<<"Enter the number of inputs:";
- cin>>n;
- cout<<"Enter the values:";
- for(int i=0;i<n;i++)
- {
- int x;
- cin>>x;
- a[i].value=x;
- if(i+1!=n)
- a[i].flink=&a[i+1];
- if(i!=0)
- a[i].blink=&a[i-1];
- }
- a[0].blink=NULL;
- a[n-1].flink=NULL;
- }
- void calc()
- {
- int l=0;
- node *start=p;
- node *last=&a[n-1];
- while(start!=NULL)
- {
- if(last->value!=start->value)
- {
- l=1;
- break;
- }
- last=last->blink;
- start=start->flink;
- }
- if(l==0)
- cout<<"True"<<endl;
- else
- cout<<"False"<<endl;
- }
- int main ()
- {
- input();
- calc();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement