湖畔读书人


私信TA

用户名:2814787590

访问量:120493

签 名:

等  级
排  名 22
经  验 18775
参赛次数 0
文章发表 42
年  龄 0
在职情况 学生
学  校 武汉东湖学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:


#include<stdio.h>

struct student
{
	char sno[20];
	char sname[20];
	int cj1;
	int cj2;
	int cj3;
};

void input(struct student st[],int n)
{
	int i;
	for(i = 0; i < n; i++){
		scanf("%s%s%d%d%d",&st[i].sno,&st[i].sname,&st[i].cj1,&st[i].cj2,&st[i].cj3);
	}
}

void print(struct student st[],int n)
{
	int i,k,sum = 0;
	for(i = 0; i < n; i++){
		if(st[i].cj1 + st[i].cj2 + st[i].cj3 > sum){
			sum = st[i].cj1 + st[i].cj2 + st[i].cj3;
			k = i;
		}
	}
	printf("%s %s %d %d %d\n",st[k].sno,st[k].sname,st[k].cj1,st[k].cj2,st[k].cj3);
}


int main()
{
	int N,i,avg1 = 0,avg2 = 0,avg3 = 0;
	struct student st[100];
	scanf("%d",&N);
	input(st,N);
	for(i = 0; i < N; i++){
		avg1 += st[i].cj1;
		avg2 += st[i].cj2;
		avg3 += st[i].cj3;
	}
	printf("%d %d %d\n",avg1/N,avg2/N,avg3/N);
	print(st,N);
	return 0;
}


 

0.0分

0 人评分

  评论区