Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 15ms
Memory: 1092kB
Author: 2016210402102
In contest: 1084

#include<stdio.h>
#include<stdlib.h>
struct student
{
	char name[100];
	int a,b;
	int s;
};
int comp(const void *p,const void *q)
{
	return ((struct student *)q)->s-((struct student *)p)->s;
}
int main()
{
	int t;
	int n;
	struct student studenta[100];
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%s%d%d",studenta[i].name,&studenta[i].a,&studenta[i].b);
			studenta[i].s=studenta[i].a+studenta[i].b;
		}
		qsort(studenta,n,sizeof(struct student),comp);
		for(int i=0;i<n;i++)
		{
			printf("%s\n",studenta[i].name);
		}
	}
}