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: 18ms
Memory: 1096kB
In contest: 1139

#include<stdio.h>
struct aaa{
	char mz[30];
	int ll,sj,tt;
}q[100],w;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int a,b,c;
		scanf("%d",&a);
		for(b=0;b<a;b++){
			scanf("%s %d %d",q[b].mz,&q[b].ll,&q[b].sj);
			q[b].tt=q[b].ll+q[b].sj;
		}
		for(b=1;b<a;b++){
			for(c=a-1;c>=b;c--){
				if(q[c].tt>q[c-1].tt){
					w=q[c];
					q[c]=q[c-1];
					q[c-1]=w;
				}
			}
		}
		for(b=0;b<a;b++){
			printf("%s\n",q[b].mz);
		}
	}
	return 0;
}