Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 12ms
Memory: 1092kB
Author: chenyuhang
In contest: 1084

#include <stdio.h>
#include<stdlib.h>
struct cyh{
char c[20];
int a,b;
int total;
};
int comp (const void *p,const void *q){
return ((struct cyh*)q)->total-((struct cyh*)p)->total;}
int main()
{	struct cyh cyh1[100];
	int d,e,f;
	scanf("%d",&d);
	while(d--){
	scanf("%d",&e);
	for(f=0;f<e;f++)
	{scanf("%s%d%d",cyh1[f].c,&cyh1[f].a,&cyh1[f].b);
	cyh1[f].total =cyh1[f].a+cyh1[f].b;
	}
	qsort(cyh1,e,sizeof(struct cyh),comp);
		for(f=0;f<e;f++)
		{
		printf("%s\n",cyh1[f].c);}
	}}