1 | A | 100 | 90 | 80 |
2 | B | 90 | 85 | 70 |
3 | C | 66 | 79 | 95 |
4 | D | 80 | 75 | 99 |
5 | E | 97 | 60 | 71 |
#include<stdio.h>
struct student{
int id;
char name[10];
float score[3];
}stu[5];
int main()
{
float sum[5]={0};
float avg[5];
float max;
float sum1=0;
int i,j,a,size,n,m;
for(i=0;i<5;i++){
scanf("%d%s",&stu[i].id,&stu[i].name);
for(j=0;j<3;j++){
scanf("%f",&stu[i].score[j]);
}
}
for(i=0;i<5;i++){
for(j=0;j<3;j++){
sum[i]+=stu[i].score[j];
}
avg[i]=sum[i]/3;
}
for(i=0;i<5;i++){
sum1+=sum[i];
}
max=sum[0];
for(n=0;n<5;n++){
if(max<sum[n]){
max=sum[n];
}
}
for(m=0;m<5;m++){
if(max==sum[m]){
break;
}
}
printf("NO. name score1 score2 score3 average\n");
for(i=0;i<5;i++){
printf("%d %s %0.2f %0.2f %0.2f %0.2f\n",stu[i].id,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],avg[i]);
}
printf("average=%0.2f\n",sum1/15);
printf("The highest score is : student %d,%s\n",stu[m].id,stu[m].name);
printf("his scores are:%6.2f,%6.2f,%6.2f,average:%0.2f.",stu[m].score[0],stu[m].score[1],stu[m].score[2],avg[m]);
return 0;
}