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

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>


	struct a {
		char name[32];
		int score[2];
		int total;
	};
	int comp (const void *p,const void *q){
		return ((struct a *)q)->total-((struct a *)p)->total;
	}
	int main(void){
		struct a hh[100];
		int i,n,T;
		scanf("%d",&T);
		while(T--){
		scanf("%d",&n);
		getchar();
		for(i=0;i<n;++i){
			scanf("%s %d %d",hh[i].name,&hh[i].score[0],&hh[i].score[1]);
			hh[i].total=hh[i].score[0]+hh[i].score[1];
		}
		qsort(hh,n,sizeof(struct a),comp);
		for(i=0;i<n;++i){
			printf("%s\n",hh[i].name);
		}
		}
	}