# include<stdio.h>
# include<stdlib.h>
typedef int ElemType;
typedef struct DuLNode
{
ElemType
data;
struct
DuLNode
*prior;
struct
DuLNode
*next;
}DuLNode,*DuLinklist;
int
Initlist(DuLinklist &L)
{
L=(DuLinklist)malloc(sizeof(DuLinklist));
L->next=L;
L->prior=L;
if(L)
return(1);
else return(0);
}
int creat(DuLinklist &L)
{
DuLinklist
p,q;int e;
p=(DuLinklist)malloc(sizeof(DuLinklist));
printf("请输入数据,以0结束\n");
scanf("%d",&e);
p->data=e;
L->next=p;
p->prior=L;
p->next=NULL;
scanf("%d",&e);
while(e!=0)
{
q=(DuLinklist)malloc(sizeof(DuLinklist));
q->data=e;
p->next=q;
q->prior=p;
q->next=NULL;
p=q;
scanf("%d",&e);
}
p->next=L;
L->prior=p;
return(1);
}
int print(DuLinklist &L)
{
DuLinklist
p;
p=L->next;
while(p)
{printf("%d\n",p->data);
p=p->next;
}
return(1);
}
void main()
{
DuLinklist L;
Initlist(L);
creat(L);
print(L);
}