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

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int comp(const void*p,const void*q)
{
	return (*(int*)p-*(int*)q);
}
int main()
{
	int t,i;
	scanf("%d",&t);
	for(i=1;i<=t;++i)
	{
		int n,m;
		char a[100][31];
		int x,y,zong[101];
		scanf("%d",&n);
		for(m=0;m<n;m++)
		{
			getchar();
			scanf("%s",a[m]);
			scanf("%d%d",&x,&y);
			zong[m]=x+y;
		}
		int pass,j,temp;
		for(pass=1;pass<n;++pass)
		{
			char b[31];
			for(j=0;j<n-pass;++j)
			{
				if(zong[j]<zong[j+1])
				{
					temp=zong[j];
					zong[j]=zong[j+1];
					zong[j+1]=temp;
					strcpy(b,a[j]);
					strcpy(a[j],a[j+1]);
					strcpy(a[j+1],b);
				}
			}
		}
		for(m=0;m<n;m++)
		{
			puts(a[m]);
		}
	}
	return 0;
}