#include <stdio.h>
#include <stdlib.h>
#define Len sizeof (struct list)
struct list
{
int x;
struct list *pre,*next;
};
struct list * Create ()//Create a linked list and return a pointer to the chain header
{
struct list *p,*p1,*head;
head=p= (struct list *) malloc (len);
P->PRE=NULL;//1. The first element does not have a direct precursor
scanf ("%d", &p->x);
int n=0;
while (P->x!=-1)
{
if (n==0)
n++;
else//understand clearly. Suggest drawing on the paper
p1->next=p,p->pre=p1;
p1=p;
p= (struct list *) malloc (len);
scanf ("%d", &p->x);
}
P1->next=null;//2. The last element has no direct successor
// p1->next=head,head->pre=p1;//If 1 2 lines of code is deleted so that's a two-way loop list.
return head;
}
int main ()
{
struct list *l1;
printf ("Please enter the list A, end with-1:");
L1=create ();
printf ("\ n");
while (L1!=null)
{
printf ("%d", l1->x);
l1=l1->next;
if (l1!=null)
printf ("%d", l1->pre->x);
}
printf ("\ n");
return 0;
}