| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 300 人关注过本帖
标题:为什么不让运行。。。哪错了啊???
只看楼主 加入收藏
欢笑LL
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-21
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
为什么不让运行。。。哪错了啊???
#include <stdio.h>
#define N 10
struct stu_info
{int num;
char name [10];
int score [3];
int total;
float aver;
}
stu [N];
void input()
{
int i;
for (i=0;i<N;i++)
{printf ("inupt the %d student xuehao, xingming ,3menkedechengji:\n",i+1);
scanf ("%d%s%d%d%d",&stu[i].num,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
}
float average ()
{
int i;
float ave=0.0;
for (i=0;i<N;i++)
{stu[i].total=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];
stu [i].aver=stu [i].total/3.0;
ave +=stu[i].aver;
}
return ave;
}
void maximum (struct stu_info*maxstu)
{
int i;
*maxstu=stu[0];
for (i=1;i<N;i++)
if (maxstu->total<stu[i].total)
*maxstu=stu[i];
}
int main()
{
struct stu_info maxstu;
float Average;
int i;
inupt ();
printf ("NO. name score1 score2 score3 total average\n");
Average=average();
for (i=0;i<N;i++)
printf ("%-8d%-8s%-5d%8d%8d%8d%8.2f\n",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].total,stu[i].aver);
printf ("Average=%.2f\n",Average);
maximum (&maxstu);
printf ("The highest score: %s,scoretotal:%d\n",maxstu.name,maxstu.total);
return 0;
}
2011-06-22 09:40
hjywyj
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:1114
专家分:2611
注 册:2010-4-14
收藏
得分:3 

inupt ();//input ();
2011-06-22 09:44
zy623132167
Rank: 2
来 自:湖北
等 级:论坛游民
帖 子:12
专家分:21
注 册:2011-6-22
收藏
得分:3 
有处警告和一处错误,错误正如楼上所说的那样,打错了,这个。、。。
警告的是你定义的数据类型不一致,一个双浮点到浮点,可能造成数据丢失,把DOUBLE 和FLOAT改成一致就好

如果三十年后这个世上还有坚持这个词!
2011-06-22 09:56
a7381526
Rank: 2
等 级:论坛游民
帖 子:10
专家分:13
注 册:2011-5-27
收藏
得分:3 
LZ加油啊。。注意细节
2011-06-22 11:07
快速回复:为什么不让运行。。。哪错了啊???
数据加载中...
 
   



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

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