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: 3ms
Memory: 1120kB
Author: 2018212212093
In contest: 1284

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int t;
	

	scanf("%d",&t);
	while(t--){
	    int n;
		scanf("%d",&n);
		getchar();
		int i=0;
		int m;
		m=n;
		char a[105][40];
        int b[105];
		while(n--){
			scanf("%s%d",a[i],&b[i]);
			getchar(); 
			i++;
		}
		int temp1=0;
	
		char tem[200];
		for(int o=0;o<m-1;o++){
			for(int e=0;e<m-o-1;e++){
			if(b[e]<b[e+1]){
				temp1=b[e+1];
				b[e+1]=b[e];
				b[e]=temp1;
				
				strcpy(tem,a[e+1]);
				strcpy(a[e+1],a[e]);
				strcpy(a[e],tem);
			}}
		}
		
		for(int q=0;q<m;q++){
			printf("%s\n",a[q]);
	
				}

		}
		
		}