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

#include<stdio.h>
struct{
	char name[30];
	int ll;
	int sj;
	int total;
}a[100],temp;
int main(){
	int t,n,i,j,z,max;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s%d%d",&a[i].name,&a[i].ll,&a[i].sj);
			a[i].total=a[i].ll+a[i].sj;
		}
		for(i=0;i<n;i++){
			max=a[i].total;
			z=i;
			for(j=i+1;j<n;j++){
				if(a[j].total>max){
					max=a[j].total;
					z=j;}}
				if(z!=i){
					temp=a[i];
					a[i]=a[z];
					a[z]=temp;}
		}
		for(i=0;i<n;i++){
			printf("%s\n",a[i].name);}
	}
	return 0;
}