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: 1204kB
Author: 2018212212038
In contest: 1284

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
int main(){
	int T,n,m,j,i,k,a[1000];
	char str[1000][100],str1[1000][100];
	scanf("%d",&T);
	while(T--){
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%s %d",str[i],&a[i]);
		}
		for(i=0;i<m;i++){
			for(j=0;j<m-i-1;j++){
				if(a[j]<a[j+1]){
					k=a[j];
					a[j]=a[j+1];
					a[j+1]=k;
					strcpy(str1[0],str[j]);
					strcpy(str[j],str[j+1]);
					strcpy(str[j+1],str1[0]);
				}
			}
		}
					for(i=0;i<m;i++){
						printf("%s\n",str[i]);
					}
	}
	return 0;
}