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

#include<stdio.h>
#include<stdlib.h> 
#define max 100          
struct student{
	char name[31];
	int a1;
	int a2;
	int total;
};
int comp(const void *p,const void *q){
	return ((struct student *)q)->total - ((struct student *)p)->total;
}
int main(){
	int t;
	struct student stu[max];
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%s",stu[i].name);
			scanf("%d",&stu[i].a1); 
			scanf("%d",&stu[i].a2); 
			stu[i].total=stu[i].a1+stu[i].a2;
		}
		qsort(stu,n,sizeof(struct student),comp);
		for(int j=0;j<n;++j){
			printf("%s\n",stu[j].name);
			
		}
	}
	return 0;
}