Start: Jan, 08, 2018 19:10:00
2017年秋季学期程序设计基础(C语言)期末考试
End: Jan, 08, 2018 21:40:00
Time elapsed:
Time remaining:

Problem_ID: E
Result: Accepted
Time: 12ms
Memory: 1104kB
In contest: 1139

#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

struct node{

	char name[50];
	int a;
	int b;
	int c;
}p[110];

bool cmp(node a, node b)
{
	return a.c > b.c;
}
int main()
{
	int t;
	scanf("%d", &t);
	while(t--)
	{
		int n, i;
		memset(p, 0, sizeof p);
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%s", &p[i].name);
			scanf("%d%d",&p[i].a, &p[i].b);
			p[i].c = p[i].a + p[i].b;
		}
		sort(p, p + n, cmp);

		for (i = 0; i < n; i++)
		{
			printf("%s\n", p[i].name);
		}
	}
	return 0;
}