[求助]谁能给双向链表的例子?
谁能给双向链表的例子?书上给的那些和网上找的五花入门的,好难理解,麻烦那位高手写个建立双向链表的例子就行,最好能有个注释,先谢了,本人太笨了,呵呵
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct student
{char name[80];
int a,b;
struct student *next;
}*creat();
struct student *creat()
{struct student *head=NULL,*tail=NULL,*p,*pp;
char name[80];
int a,b;
int size=sizeof(struct student);
scanf("%s%d%d",name,&a,&b);
while (a!=0){
p=(struct student *)malloc(size);
p->a=a;p->b=b;p->next=NULL;
strcpy(p->name,name);
if (head==NULL)
head=tail=p;
else
tail->next=p;
tail=p;
scanf("%s%d%d",name,&a,&b);}
for (pp=head;pp;pp=pp->next)
printf("%-7s%-5d%-5d\n",pp->name,pp->a,pp->b);
return (head);
}
void main()
{struct student *head;
head=creat();
}
这是一个单向链表,请问怎么改就变成双向链表呢?