View Code of Problem 82

#include<bits/stdc++.h>
using namespace std;
typedef struct{
	string no;
	string name;
	int a;
	int b;
	int c;
	int Z;//总分 
}Stu;
bool cmp(Stu a,Stu b){
	return a.Z>b.Z;
}
int main() {
	Stu stu[100];
	int n;
	int a1=0,b1=0,c1=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>stu[i].no>>stu[i].name>>stu[i].a>>stu[i].b>>stu[i].c;
		stu[i].Z=stu[i].a+stu[i].b+stu[i].c;
		a1+=stu[i].a;
		b1+=stu[i].b;
		c1+=stu[i].c;
	}
	sort(stu,stu+n,cmp);
	cout<<a1/n<<" "<<b1/n<<" "<<c1/n<<endl<<stu[0].no<<" "<<stu[0].name<<" "<<stu[0].a<<" "<<stu[0].b<<" "<<stu[0].c;
	return 0;
}

Double click to view unformatted code.


Back to problem 82