#include<malloc.h>
#include<stdio.h>
typedef struct Dnode
{int data;
struct Dnode *prior;
struct Dnode *next;}Dnode,*Linklist;
Linklist create()
{Linklist l,p;
int t=1;
l=(Linklist)malloc(sizeof(Dnode));
l->next=NULL;
l->prior=l->next;
printf("Input '0' to create a dulinklist!\n");
p=(Linklist)malloc(sizeof(Dnode));
scanf("%d",&t);
p->data=t;
p->prior=l;
l->next=p;
p->next=l->prior;
while(t!=0)
{p=(Linklist)malloc(sizeof(Dnode));
scanf("%d",&t);
if(t==0) break;
p->data=t;
p->next=l->next;
l->next->prior=p;
p->prior=l;
l->next=p;
}
return l;
}
print(Linklist h)
{Linklist p;
p=h->next;
printf("\nNow the dulinklist as follows:\n");
while(p!=h->prior)
{printf("%d",p->data);
p=p->next;
}
}
symmetry(Linklist l,int t)
{Linklist p,q;
t=1;
p=l->next;
q=l->prior;
if(p->data!=q->data)
printf("\nIsn't symmetry!\n");
while(p!=q&&p->prior!=q)
{p=p->next;q=q->prior;
if(p->data!=q->data)
{printf("\nIsn't symmetry!\n");
t=0;
break;}
}
return t;
}
main()
{Linklist l;
int s=1;
l=create();
print(l);
s=symmetry(l, s);
if(s!=0)
printf("\nIs symmetry!\n");
}