//双链表
typedef struct student
{
int data;
struct student *next;
struct student *pre;
}dnode;
//建立双链表
dnode *creat()
{
dnode *head, *p, *s;
int x, cycle = 1;
head = (dnode*)malloc(sizeof(dnode));
p = head;
while(cycle)
{
printf("\nplease input the data:");
scanf("%d", &x);
if( x != 0 )
{
s = (dnode*)malloc(sizeof(dnode));
s->data = x;
printf("\n %d", s->data);
p->next = s;
s->pre = p;
p = s;
}
else
cycle = 0;
}
head = head->next;
head->pre = NULL;
p->next = NULL;
printf("\n yyy %d", head->data);
return head;
}
typedef struct student
{
int data;
struct student *next;
struct student *pre;
}dnode;
//建立双链表
dnode *creat()
{
dnode *head, *p, *s;
int x, cycle = 1;
head = (dnode*)malloc(sizeof(dnode));
p = head;
while(cycle)
{
printf("\nplease input the data:");
scanf("%d", &x);
if( x != 0 )
{
s = (dnode*)malloc(sizeof(dnode));
s->data = x;
printf("\n %d", s->data);
p->next = s;
s->pre = p;
p = s;
}
else
cycle = 0;
}
head = head->next;
head->pre = NULL;
p->next = NULL;
printf("\n yyy %d", head->data);
return head;
}