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

#include<stdio.h>
struct a{
	char name[20];
	int x;
	int y;
};
int main(void)
{
	struct a yh[101];
	struct a zy;
	int t,z,x,c,v,b;
	b=0;b++;
	scanf("%d",&t);
	while(t--)
	{
		int i,j;
		scanf("%d",&z);
		for(x=0;x<z;x++)
		{
			scanf("%s%d%d",yh[x].name,&yh[x].x,&yh[x].y);

		}
		for(i=1;i<z;i++)
		{
			for(j=0;j<z-i;j++)
			{
				if((yh[j].x+yh[j].y)>(yh[j+1].x+yh[j+1].y))
				{
					zy=yh[j];
					yh[j]=yh[j+1];
					yh[j+1]=zy;
				}
			}
		}
		for(i=z-1;i>=0;i--)
		{

			printf("%s\n",yh[i].name);
		}

	}
	return 0;
}