双向连表
#include "stdlib.h"
#include "stdio.h"
struct node
{struct node *frist;
int d;
struct node *next;}
main()
{int x;
struct node *head,*p,*q;
head=NULL;
q=NULL;
scanf("%d",&x);
while(x>0)
{p=(struct node *)malloc(sizeof(struct node));
p->first=NULL;
p->d=x;
p->next=NULL;
if(head==NULL)head=p;
else {p->first->next=p->next;
p->next->first=p->first;}
q=p;
scanf("%d",&x);
}
p=head;
while(p!=NULL)
{printf("%5d",p->d);
q=p;p=p->next;
}
printf("\n");
}