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: 2016210402094
In contest: 1084

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