#include <stdio.h>
#include <stdlib.h>
typedef struct DuLNode
{char data;
struct DuLNode *prior,*next;
}DuLNode,*DuLinkList;
//建立双向循环链表
DuLinkList Create(void){
char ch;
DuLinkList head=(DuLinkList)malloc(sizeof(DuLNode));
DuLinkList s,r;
head->next=NULL;
head->prior=NULL;
r=head;
while((ch=getchar())!='\n'){
s=(DuLNode*)malloc(sizeof(DuLNode));
s->data=ch;
r->next=s;
s->prior=r;
r=s;
}
r->next=head;
head->prior=r;
return head;
}
//打印
void Print(DuLinkList head){
DuLinkList p;
for(p=head->next;p!=head;p=p->next)
printf("%c",p->data);
printf("\n");
}
//判断双向循环链表是否对称
int DuiChen(DuLinkList head){
DuLinkList p,q;
int i=1;
p=head->next;
q=p;
while(q->next!=head)
{
q=q->next;
i++;}
if(i<4&&p->data==q->data)
return 1;
if(i>=4){
while(q->next!=p){
if(q->data==p->data){p=p->next;
q=q->prior;}
else return 0;}
return 1;}
}
void main()
{int x;
DuLinkList head;
head=Create();
Print(head);
x=DuiChen(head);
printf("%d",x);
}