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: 12ms
Memory: 1092kB
Author: 2016212402008
In contest: 1084

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