#include <cstdio> #include <string> #include <iostream> #include <algorithm> using namespace std; struct student{ string id; string name; double a; double b; double c; double sum; }; bool cmp(student a,student b){ return a.sum>b.sum; } int main(){ int n; cin>>n; student stu[n]; double aa=0,bb=0,cc=0; for(int i=0;i<n;i++){ cin>>stu[i].id>>stu[i].name>>stu[i].a>>stu[i].b>>stu[i].c; stu[i].sum=stu[i].a+stu[i].b+stu[i].c; aa+=stu[i].a; bb+=stu[i].b; cc+=stu[i].c; } sort(stu,stu+n,cmp); printf("%.0f %.0f %.0f\n",aa/n,bb/n,cc/n); cout<<stu[0].id<<" "<<stu[0].name<<" "<<stu[0].a<<" "<<stu[0].b<<" "<<stu[0].c<<endl; } |
Double click to view unformatted code.