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<string.h>
struct name
{
	char a[40];
	int c1;
	int c2;
	int c;
};
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,i,j;
		struct name b[120],tem;
		scanf("%d",&n);
		for(i=0;i<n;++i)
		{
			scanf("%s %d %d",b[i].a,&b[i].c1,&b[i].c2);
			b[i].c =b[i].c1+b[i].c2;
		}
		for(j=1;j<n;++j)
		{
			for(i=0;i<n-j;++i)
			{
				if(b[i].c<b[i+1].c)
				{
					tem=b[i];
					b[i]=b[i+1];
					b[i+1]=tem;
				}
			}
		}
		for(i=0;i<n;++i)
		{
			printf("%s\n",b[i].a);
		}
	}
	return 0;
}