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: yeruibin200
In contest: 1141

#include<stdio.h>
#include<string.h>
struct student{
	int mark;
	char name[30];
};
typedef struct student Student;
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int n;
		Student arrary[100];
		scanf("%d",&n);
		getchar();
		for(int i =0;i<n;++i){
			int a,b;
			scanf("%s %d %d",&arrary[i].name,&a,&b);
			arrary[i].mark=a+b;
		}
		Student temp;
		for(int i=0;i<n;++i){
			for(int j=i;j>0;--j){
				if(arrary[j].mark>arrary[j-1].mark){
					temp = arrary[j];
					arrary[j]=arrary[j-1];
					arrary[j-1]=temp;
				}
			}
		}
		for(int i=0;i<n;++i)
			printf("%s\n",arrary[i].name); 
		
	}
}