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: 10ms
Memory: 1092kB
In contest: 1139

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