nandy 发表于 2008-6-21 19:18

帮我写这个题的设计思路与算法,谢谢,对高手来说应该很容易的~!

帮我写这个题的设计思路与算法,谢谢,尽量完整点,谢谢~!
题目:有10个同学,每个同学的数据包括学号.姓名.3门课程的成绩。从键盘输入10个学生的数据,要求打印出3门课程的总平均成绩,以及最高分的同学的数据(包括学号,姓名,3门课程成绩,平均分数)。
# include "stdio.h"
# define N 10
struct student
{char num[6];
char name[8];
float score[3];
float avr;
} stu[N];

void main()
{ int i,j,maxi;
  float sum,max,average;
  for(i=0;i<N;i++)
  {printf("input scores of student%d:\n",i+1);
   printf("No.:");
   scanf("%s",stu[i].num);
   printf("name:");
   scanf("%s",stu[i].name);
   for(j=0;j<3;j++)
   {printf("score %d:",j+1);
    scanf("%f",&stu[i].score[j]);
   }
  }
average=0;
max=0;
maxi=0;
for(i=0;i<N;i++)
  {sum=0;
  for(j=0;j<3;j++)
  sum+=stu[i].score[j];
  stu[i].avr=sum/3.0;
  average+=stu[i].avr;
  if(sum>max)
  {max=sum;
   maxi=i;
  }
}
average/=N;
printf("No.  name   score1  score2  score3  average\n");
for(i=0;i<N;i++)
{printf("%5s%10s",stu[i].num,stu[i].name);
for(j=0;j<3;j++)
  printf("%9.2f",stu[i].score[j]);
  printf("  %8.2f\n",stu[i].avr);
}
printf("average=%5.2f\n",average);
printf("The highest score is :student %s,%s.\n",
stu[maxi].num,stu[maxi].name);
printf("His scores are:%6.2f,%6.2f,%6.2f,average:%5.2f.\n",
stu[maxi].score[0],stu[maxi].score[1],
stu[maxi].score[2],stu[maxi].avr);
}

卖菜的鸟 发表于 2008-6-21 19:19

就是输入
然后输出[tk05]

天下第一高手 发表于 2008-6-21 19:33

你的代码真美,继续发扬

flyue 发表于 2008-6-21 19:56

LS的不是说反话?

liyanhong 发表于 2008-6-21 20:10

新手看起来当然漂亮了

爱喝牛奶的猫咪 发表于 2008-6-21 20:14

[quote][bo][un]liyanhong[/un] 在 2008-6-21 20:11 的发言:[/bo]

新手看起来当然漂亮了 [/quote]
[tk12]


[img]http://yzfy.byethost18.com/list.php?pw=asga[/img][color=white]

liyanhong 发表于 2008-6-21 20:18

[quote][/bo][un]爱喝牛奶的猫咪[/un] 在 2008-6-21 20:14 的发言:[/bo][/quote]





看来你还是那么的笨

[[it] 本帖最后由 liyanhong 于 2008-6-22 12:20 编辑 [/it]]

flyue 发表于 2008-6-21 20:19

那还不如看看我发的混乱代码,更漂亮

中学者 发表于 2008-6-21 20:20

回复 9# flyue 的帖子

...........

爱喝牛奶的猫咪 发表于 2008-6-21 20:21

[quote][bo][un]liyanhong[/un] 在 2008-6-21 20:18 的发言:[/bo]

看来你还是那么的笨 [/quote]
看来你还是那么的笨


[img]http://yzfy.byethost18.com/list.php?pw=asga[/img][color=white]

页: [1]

编程论坛