View Code of Problem 82

#include<bits/stdc++.h>
using namespace std;
typedef struct student{
	string s1;
	string s2;
	int a,b,c;
	int sum;
};
int main(){
	double e=0,f=0,g=0;
	int n,t;
	cin>>n;
	student stu[n];
	for(int i=0;i<n;i++){
		cin>>stu[i].s1>>stu[i].s2>>stu[i].a>>stu[i].b>>stu[i].c;
		stu[i].sum=stu[i].a+stu[i].b+stu[i].c;
		e=e+stu[i].a;
		f=f+stu[i].b;
		g=g+stu[i].c;
	}
	cout<<e/n<<" "<<f/n<<" "<<g/n<<endl;
	for(int i=0;i<n;i++){
		if(stu[t].sum<stu[i].sum) t=i; 
	}
	cout<<stu[t].s1<<" "<<stu[t].s2<<" "<<stu[t].a<<" "<<stu[t].b<<" "<<stu[t].c;
}

Double click to view unformatted code.


Back to problem 82