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

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int i,j,t,n,q[101],temp;
	char p[101][21],temps[101];
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%s %d",&p[i],&q[i]);
		for(i=0;i<n-1;i++){
			for(j=0;j<n-1-i;j++){
				if(q[j]>q[j+1]){
					temp=q[j+1];
					q[j+1]=q[j];
					q[j]=temp;
					strcpy(temps,p[j+1]);
					strcpy(p[j+1],p[j]);
					strcpy(p[j],temps);
				}
			}
		}
		for(i=n-1;i>=0;i--)
			printf("%s\n",p[i]);
	}
    return 0;
}