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

#include<stdio.h>
#include<stdlib.h>
struct f{
	char name[20];
	int li;
	int shi;
	int amount;
};
int comp(const void * p,const void *q){
	return ((struct f *)q)->amount-((struct f *)p)->amount;
}
int main(){
	struct f loy[100];
	int i,j,k,T,N;
	scanf("%d",&T);
	for(i = 1 ; i <= T ; ++ i){
		scanf("%d",&N);
		for(j = 0 ; j < N ; ++ j){
			getchar();
			scanf("%s %d %d",loy[j].name,&loy[j].li,&loy[j].shi);
			loy[j].amount = loy[j].li+loy[j].shi;
		}
		qsort(loy,N,sizeof(struct f),comp);
		for(j = 0 ; j < N ;++ j)
			printf("%s\n",loy[j].name);
	}
	return 0;
}