| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 613 人关注过本帖
标题:关于建立动态链表的问题
只看楼主 加入收藏
c盘格式化
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2007-4-3
收藏
 问题点数:0 回复次数:2 
关于建立动态链表的问题
题目是建立一个动态链表,请各位大侠帮我看一下哪里出错了,我看了N久都没有找出错误
#include<iostream.h>
#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
int num;
int score;
struct student *next;
};
int n;
struct student *cread(void)
{
struct student *head,*p1,*p2;
n=0;
head=NULL;
while(p1->num!=0)
{
p1=(struct student*)malloc(LEN);
n++;
cout<<"please iput the numble and score:";
cin>>p1->num;
cin>>p1->score;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
}
p1->next=NULL;
return(head);
}
int main()
{
struct student *p;
p=cread();
return 0;
}
搜索更多相关主题的帖子: 链表 动态 
2007-05-19 17:18
ibiancheng
Rank: 1
等 级:新手上路
帖 子:148
专家分:0
注 册:2007-4-3
收藏
得分:0 
你说说看出现什么状况了么。。。
int main()
{
struct student *p;
p=cread();/*创建了动态链表别忘记用完之后要释放链表所占用的内存*/
return 0;
}

执著的信念,坚定的自信,勤奋的努力才是通向成功的捷径! !!
2007-05-19 17:28
neverTheSame
Rank: 3Rank: 3
来 自:江西农业大学
等 级:新手上路
威 望:9
帖 子:1511
专家分:0
注 册:2006-11-24
收藏
得分:0 
#include<stdio.h> 中已经宏定义了 NULL

#define NULL 0

wap酷禾网(http://wap.),提供免费的、优质的、快捷的wap资源下载服务。
2007-05-19 20:36
快速回复:关于建立动态链表的问题
数据加载中...
 
   



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

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