#include<bits/stdc++.h> using namespace std; struct student { string id; string name; double x, y, z; double sum; }a[10010]; bool cmp(student a, student b) { return a.sum > b.sum; } int main() { int n; cin >> n; int sum = 0; int x = 0, y = 0, z = 0; for (int i = 0; i < n; i++) { cin >> a[i].id >> a[i].name >> a[i].x >> a[i].y >> a[i].z; a[i].sum = a[i].x + a[i].y + a[i].z; x += a[i].x; y += a[i].y; z += a[i].z; } sort(a, a + n, cmp); cout << x / n << " " << y / n << " " << z / n << endl; cout << a[0].id << " " << a[0].name << " " << a[0].x << " " << a[0].y << " " << a[0].z << endl; } |
Double click to view unformatted code.