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

#include <stdio.h>
#include <stdlib.h>
struct stu {
	int x;
	int y;
	char name[50];
	int total;
};
int comp(const void *p,const void *q){
	return ((struct stu *)q)->total-((struct stu *)p)->total;
}
int main ()
{
	int t;
	scanf("%d",&t);
	int n,i=0;
	struct stu chengji[100];
	while(t--){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s %d %d",&chengji[i].name,&chengji[i].x,&chengji[i].y);
			chengji[i].total=chengji[i].x+chengji[i].y;
		}
	qsort(chengji,n,sizeof(struct stu),comp);
	for(i=0;i<n;i++){
		printf("%s\n",chengji[i].name);
	}
	}
}