| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 488 人关注过本帖
标题:请大家帮忙寻找错误,不要正确答案(因为只有知道错误在哪里,下次才能够避 ...
取消只看楼主 加入收藏
小戏
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-7-11
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:1 
请大家帮忙寻找错误,不要正确答案(因为只有知道错误在哪里,下次才能够避免)
#include<stdio.h>
#include<malloc.h>

#define LEN sizeof(struct student)
struct student
    {int num;

    float score;
    struct student *next;
    };
   int n;
struct student *creat()
{struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%d,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)
head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student*)malloc(LEN);
scanf("%d,%f",&p1->num,&P1->score);
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{struct student *p;
printf("\nNow,These%d records are:\n",n);
p=head;
if(head!=NULL)
do
{printf("%1d %f\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
}
void main()
{
struct student *head;
head=creat();
print(head);

}
搜索更多相关主题的帖子: 正确答案 next include return 
2012-08-20 11:24
小戏
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-7-11
收藏
得分:0 
谢谢各位大侠了,说实话,正确的程序我也有,也能够运行出正确的结果,但就是上面这个程序无法通过调试,我把两个程序比较了不下10遍,就是找不出问题的所在,实在是不甘心,所以才请教各位师兄的。真的谢谢大家了!
2012-08-20 23:39
快速回复:请大家帮忙寻找错误,不要正确答案(因为只有知道错误在哪里,下次才能 ...
数据加载中...
 
   



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

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