标题:[求助]谁能给双向链表的例子?
取消只看楼主
wwjazz
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-8-24
 问题点数:0 回复次数:2 
[求助]谁能给双向链表的例子?
谁能给双向链表的例子?书上给的那些和网上找的五花入门的,好难理解,麻烦那位高手写个建立双向链表的例子就行,最好能有个注释,先谢了,本人太笨了,呵呵
搜索更多相关主题的帖子: 链表 例子 
2006-09-02 15:02
wwjazz
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-8-24
得分:0 

#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();


这是一个单向链表,请问怎么改就变成双向链表呢?


2006-09-02 15:34
wwjazz
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-8-24
得分:0 
嘿嘿,感谢楼上的,学习ING~~~~~~~

2006-09-02 16:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-87582-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.400840 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved