私信TA

用户名:wdxb

访问量:867

签 名:

等  级
排  名 11872
经  验 958
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校 中国矿业大学
专  业

  自我简介:

TA的其他文章

解题思路:先定义输入,再定义输出,看代码吧

注意事项:比较最好层级那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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区