鱼C论坛

 找回密码
 立即注册
查看: 5068|回复: 14

求问???急~~~~谢谢谢

[复制链接]
发表于 2013-6-6 09:03:15 | 显示全部楼层 |阅读模式
3鱼币
psbCAO1BRFS.jpg 怎么输出这样的结果呃???。
# include <stdio.h>
struct student
{
   char name[50];
   int  score;
   float average;
   
};
void main(void)
{
int j,i;
struct student s[5]={
{"student1",100},
{"student2",90},
{"student3",80},
{"student4",90},
{"student5",100}
};
for(j=1; j<5;j++)
{
printf("input student%d name:");
scanf("%d",&s[j].score);
}
for(i=1;i<5;i++)
{
printf("student%s score: %d\n",s[j].name,s[j].score);
}
s[j].average = (s[j].student1 + s[j].student2 + s[j].student3+s[j].student4+s[j].student5)/5;

printf("average= %f \n",s[i].average);
}
我写的错了很多,思维混乱中~~~~求教昂!!!谢谢谢啦
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 09:03:16 | 显示全部楼层
  1. # include <stdio.h>
  2. struct student
  3. {
  4.         char name[50];
  5.         int  score;       
  6. };
  7. void main(void)
  8. {
  9.         int i,sum = 0;
  10.         float average = 0.0;
  11.         struct student s[5];

  12.         for(i=1; i<=5;i++)
  13.         {
  14.                 printf("input student%d name: ",i);
  15.                 scanf("%s",s[i].name);
  16.                 printf("input the score of %s ",s[i].name);
  17.                 scanf("%d",&s[i].score);
  18.         }
  19.         for(i=1;i<=5;i++)
  20.         {
  21.                 printf("student %s score: %d\n",s[i].name,s[i].score);
  22.                 sum = sum+s[i].score;
  23.         }

  24.        
  25.         printf("average= %f \n",sum / (5.0));
  26. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-6-6 09:16:08 | 显示全部楼层
还是别看我写的了,免得影响思路
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 12:17:50 | 显示全部楼层
强烈支持楼主。。。。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-6-6 12:22:33 | 显示全部楼层
为嘛那么多人看,没人帮忙解答一下啊啊啊啊???是太难了还是太简单啦???
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 12:49:45 | 显示全部楼层
多向飞碟读书方法的
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-6-6 12:52:08 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 12:54:05 | 显示全部楼层
史蒂芬森地方上的
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 13:08:11 | 显示全部楼层
修改半天,给你修改好了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 13:10:31 | 显示全部楼层
  1. # include <stdio.h>
  2. struct student
  3. {
  4.     char name[50];
  5.     int  score;
  6.    
  7. };
  8. void main()
  9. {
  10. int i;
  11. float average,total=0;
  12. struct student s[5];

  13. for(i=1; i<=5;i++)
  14. {
  15. printf("input student%d score:",i);
  16. scanf("%d",&s[i-1].score);
  17. }
  18. for(i=1;i<=5;i++)
  19. {
  20. printf("student%d score: %d\n",i,s[i-1].score);
  21. total=total+s[i-1].score;
  22. }
  23. average=total/5.0;

  24. printf("average= %f \n",average);
  25. }//修改好了,,,建议你多看看优秀代码,这写的也确实有点乱
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-6-6 13:20:50 | 显示全部楼层

好吧好吧谢啦正在学习中的嘛。。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-6-6 13:23:13 | 显示全部楼层
丝连 发表于 2013-6-6 12:17
强烈支持楼主。。。。

呃呃呃呃呃谢谢支持呃
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-6 19:36:14 | 显示全部楼层
ミLuyo 发表于 2013-6-6 13:23
呃呃呃呃呃谢谢支持呃

{:7_155:}只有晚上才有时间上来学习啊!!加油~~
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-7 13:53:15 | 显示全部楼层

感觉有点问题啊....
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-6-7 13:56:09 | 显示全部楼层
楼主加油~~
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-26 14:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表