Start: Jul, 10, 2019 08:30:00
2019年度暑期短学期达标测试补考
End: Jul, 10, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 4ms
Memory: 1120kB
Author: 2018212212040
In contest: 1284

#include<stdio.h>
#include<string.h>
#include<math.h>
struct node{
	char name[21];
	int num;
}wh[100];
int main()
{
	int t,n;
	struct node temp;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%s %d",wh[i].name,&wh[i].num);
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(wh[j].num>wh[i].num){
				temp=wh[i];wh[i]=wh[j];wh[j]=temp;
				}
			}
		}
		for(int i=0;i<n;i++){
			printf("%s\n",wh[i].name);
		}
		memset(wh,0,sizeof wh);
	}

	return 0;
}