Start: Mar, 06, 2018 09:46:00
计算机161 算法分析与设计 第一次实验课作业(吴银杰、张凯庆)
End: Mar, 10, 2018 10:00:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 11ms
Memory: 1092kB
Author: 2016210401015
In contest: 1141

#include<stdio.h>
struct student
{
int num;
char name[31];
};
int main(void){
	int t;
		struct student st[101],m;
	scanf("%d",&t);
	while(t--){
	
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			int x,y;
			scanf("%s %d %d",st[i].name,&x,&y);
			st[i].num=x+y;
		}
		
	   for(int i=0;i<n-1;i++){
			for(int j=0;j<n-i-1;j++){
				if(st[j].num<st[j+1].num){
					m=st[j+1];
					st[j+1]=st[j];
					st[j]=m;
				}
			}
		}
		for(int i=0;i<n;i++)
		printf("%s\n",st[i].name);

	}
}