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: 2018212212234
In contest: 1284

#include<stdio.h>
struct chenghao{
	char a[21];
	int x;
};
int main(){
int t,i,n,j,pass,temp,b[101];
struct chenghao s[101];
scanf("%d",&t);
while(t--){
	scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%s %d",&s[i].a,&s[i].x);
	b[i]=s[i].x;
}
for(pass=1;pass<n;pass++){
	for(i=0;i<n-pass;i++){
		if(b[i]<b[i+1]){
			temp=b[i];
			b[i]=b[i+1];
			b[i+1]=temp;
		}
	}
}
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		if(b[i]==s[j].x)
	printf("%s\n",s[j].a);
	}
}
}	
}