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: 13ms
Memory: 1092kB
In contest: 1139

#include<stdio.h>
#include<stdlib.h>
#define size 100
struct man{
	char name[30];
	int shu1,shu2;
	int shu3;
};
int comp(const void *p,const void *q){
	return ((struct man *)q)->shu3-((struct man *)p)->shu3;
}
int main(void){
	int a,b,i,j;
	struct man str[size];
	scanf("%d",&a);
	while(a>0){
		scanf("%d",&b);
		for(i=0;i<b;++i){
			scanf("%s %d %d",str[i].name,&str[i].shu1,&str[i].shu2);
			str[i].shu3=str[i].shu1+str[i].shu2;
		}
		qsort(str,b,sizeof(struct man),comp);
		for(j=0;j<b;++j){
			printf("%s\n",str[j].name);
		}
		a=a-1;
	}
		return 0;
}