#include <iostream>
#include <stdlib.h>
using namespace std;
typedef struct node
{
int num;
struct node* prior;
struct node* next;
}NODE,*PNODE;
PNODE creat_(int n)//建立循环双向链表
{
int num_;
PNODE head,p,q;
head=(PNODE)malloc(sizeof(NODE));
if(head==NULL)
{
cout<<"fault";
}
head->next=NULL;
q=head;
while(n--)
{
p=(PNODE)malloc(sizeof(NODE));
cin>>num_;
p->num=num_;
q->next=p;
p->prior=q;
q=p;
}
q->next=head;
head->prior=q;
return head;
}
void traverse(PNODE head)
{
PNODE q=head->prior;
while(q!=head)
{
cout<<q->num<<' ';
q=q->prior;
}
}
int main()
{
PNODE head;
head=creat_(7);
traverse(head);
}