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

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define size 200
struct student
{
	char name[31];
	int a;
	int b;
	int all;
};
int comp(const void *p,const void *q)
{
	return ((struct student *)q)->all-((struct student *)p)->all;
}
int main()
{
	int T,i,len,k,flag;
	long int n,j;
	struct student olw[size];
	scanf("%d",&T);
	for(i=0;i<T;i++)
	{
		scanf("%d",&n);
		for(j=0;j<n;j++)
		{
			scanf("%s%d%d",olw[j].name,&olw[j].a,&olw[j].b);
			olw[j].all=olw[j].a+olw[j].b;
		}
		qsort(olw,n,sizeof(struct student),comp);
		for(j=0;j<n;j++)
		{
			printf("%s\n",olw[j].name);
		}
	}
	return 0;
}