解题思路:先定义输入,再定义输出,看代码吧
注意事项:比较最好层级那lop要=-1,不能忘了
参考代码:
#include<stdio.h>
typedef struct student
{
char id[101];
char name[101];
int score[3];
}stu;
void input(stu a[],int n)
{
for(int i=0;i<n;i++)
{
scanf(" %s %s %d %d %d",a[i].id,a[i].name,&a[i].score[0],&a[i].score[1],&a[i].score[2]);
}
}
void output(stu a[],int n)
{
int sum[3]={0},max=0,lop=-1;
for(int i=0;i<n;i++)
{
sum[0]+=a[i].score[0];
sum[1]+=a[i].score[1];
sum[2]+=a[i].score[2];
int tempmax=a[i].score[0]+a[i].score[1]+a[i].score[2];
if(max<tempmax)
{
lop=i;
max=tempmax;
}
}
printf("%d %d %d\n%s %s %d %d %d",sum[0]/n,sum[1]/n,sum[2]/n,a[lop].id,a[lop].name,a[lop].score[0],a[lop].score[1],a[lop].score[2]);
}
int main(){
int n;
scanf("%d",&n);
struct student a[100];
input(a,n);
output(a,n);
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.5 (C++代码)浏览:459 |
用筛法求之N内的素数。 (C语言代码)浏览:835 |
求圆的面积 (C语言代码)浏览:1699 |
DNA (C语言代码)浏览:540 |
小九九 (C语言描述,不看要求真坑爹)浏览:986 |
分糖果 (C语言代码)浏览:921 |
Pascal三角 (C语言代码)浏览:654 |
复数求和 (C语言代码)浏览:930 |
小O的乘积 (C语言代码)浏览:1016 |
1415题求解浏览:637 |