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

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
struct sb{
	char name [22];
	int a;
	int b;
	int num;
};
int comp(const void *p,const void*q){
	return ((struct sb *)q)->num-((struct sb *)p)->num;
}
int main () {
	int t;
	int n;
	int i;
	struct sb student[110];
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s %d %d",student[i].name,&student[i].a,&student[i].b);
			student[i].num=student[i].a+student[i].b;
		}

		qsort (student,n,sizeof(struct sb),comp);
		for(i=0;i<n;i++){
			printf("%s\n",student[i].name);
		}

	
	}


}