View Code of Problem 82

#include<iostream>
#include<cstdio>

using namespace std;

struct student
{
	string num;
	string name;
	int a;
	int b;
	int c;
	int t;
};

int main()
{
	int n;
	long long at = 0, bt = 0, ct = 0;
	int pos = 0;
	scanf("%d", &n);
	struct student stu[n];
	for(int i = 0; i < n; i++)
	{
		cin >> stu[i].num >> stu[i].name >> stu[i].a >> stu[i].b >> stu[i].c;
		stu[i].t = stu[i].a + stu[i].b + stu[i].c;
		at += stu[i].a;
		bt += stu[i].b;
		ct += stu[i].c;
	}
	printf("%d %d %d\n", at/n, bt/n, ct/n);
	for(int i = 1; i < n; i++)
		if(stu[pos].t < stu[i].t)
			pos = i;
	printf("%s %s %d %d %d", stu[pos].num.c_str(), stu[pos].name.c_str(), stu[pos].a, stu[pos].b, stu[pos].c);
	return 0;
}

Double click to view unformatted code.


Back to problem 82