计科院20许籍元


私信TA

用户名:uq_48412616658

访问量:941

签 名:

等  级
排  名 1654
经  验 2634
参赛次数 5
文章发表 3
年  龄 19
在职情况 学生
学  校 怀化学院
专  业 数据科学与大数据技术

  自我简介:

#include<stdio.h>
struct stu{
	char num[100];
	char name[100];
	int score[3];
}; 
void input(struct stu *a,int n);
void output(struct stu *a,int n);
int main(){
	int n;
	scanf("%d",&n);
	struct stu a[n];
	input(a,n);
	output(a,n);
	
	return 0;
}
void input(struct stu *a,int n){
	int i;
	for(i=0;i<n;i++){
		scanf("%s%s%d%d%d",&(a[i].num),&(a[i].name),
		&(a[i].score[0]),&(a[i].score[1]),&(a[i].score[2]));
	}
}
void output(struct stu *a,int n){
	int i,j,t1,t2,max;
	max = a[1].score[0];
	int ave0=0,ave1=0,ave2=0;
	for(i=0;i<n;i++){
		ave0 += a[i].score[0];
		ave1 += a[i].score[1];
		ave2 += a[i].score[2];
		for(j=0;j<3;j++){
			if(max <= a[i].score[j]){
				max = a[i].score[j];
				t1 = i;
				
			}
		}
	}
		printf("%d %d %d\n",ave0/n,ave1/n,ave2/n);
		printf("%s %s %d %d %d\n",a[t1].num,a[t1].name,a[t1].score[0],
		a[t1].score[1],a[t1].score[2]);
}

解题思路:

注意事项:

参考代码:

 

0.0分

1 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区