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

#include<stdio.h>
#include<stdlib.h>
struct qimu{
	char name[30];
	int lilun;
	int shi;
	int total;
};
int comp(const void *p,const void*q){
	return((struct qimu*)q)->total - ((struct qimu*)p)->total; 
}
int main(){
	int T,N,i;
	struct qimu qw[100]={0};
	scanf("%d",&T);
	while(T--){
		struct qimu qw[100]={0};
		scanf("%d",&N);
		for(i=0;i<N;i++){
			getchar();
		    scanf("%s%d%d",&qw[i].name,&qw[i].lilun,&qw[i].shi);
			qw[i].total=qw[i].lilun+qw[i].shi;
		}
		qsort(qw,N,sizeof(struct qimu),comp);
		for(i=0;i<N;i++)
		     printf("%s\n",qw[i].name);

	
	}
	return 0;
}