解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <stdlib.h>
struct score
{
char number[20];
char name[20];
int grades[3];
int sum;
};
void pj(struct score *a,int *sum1,int *sum2,int *sum3)
{
*sum1+=a->grades[0];
*sum2+=a->grades[1];
*sum3+=a->grades[2];
a->sum=a->grades[0]+a->grades[1]+a->grades[2];
}
void input(struct score *a)
{
scanf("%s%s%d%d%d",a->number,a->name,&(a->grades[0]),&(a->grades[1]),&(a->grades[2]));
}
int main()
{
int count;
scanf("%d",&count);
int sum1=0,sum2=0,sum3=0;
struct score message[count];
int i=0;
for(;i<count;i++)
{
input(&(message[i]));
pj(&(message[i]),&sum1,&sum2,&sum3);
}
printf("%d %d %d\n",sum1/count,sum2/count,sum3/count);
int max=0;
for(i=0;i<count-1;i++)
{
if(message[i].sum<message[i+1].sum)
{
max=i+1;
}
}
printf("%s %s %d %d %d",message[max].number,message[max].name,message[max].grades[0],message[max].grades[1],message[max].grades[2]);
return 0;
}
0.0分
0 人评分