View Code of Problem 82

#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;

struct stu{
	string i;
	string name;
	int a,b,c;
	double avg;
};

bool cmp(stu a,stu b){
	return a.avg>b.avg;
}

int main(){
	
	int n;
	cin>>n;
	stu s[n];
	int a=0,b=0,c=0;
	for(int i=0;i<n;i++){
		cin>>s[i].i>>s[i].name>>s[i].a>>s[i].b>>s[i].c;
		a+=s[i].a; b+=s[i].b;  c+=s[i].c;
		s[i].avg=(s[i].a+s[i].b+s[i].c)/3;
	}
	cout<<a/n<<" "<<b/n<<" "<<c/n<<endl;
	sort(s,s+n,cmp);
	cout<<s[0].i<<" "<<s[0].name<<" "<<s[0].a<<" "<<s[0].b<<" "<<s[0].c<<endl;
	
	
	return 0;
		
}

Double click to view unformatted code.


Back to problem 82