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

#include<stdio.h>
#include<string.h>
struct student{
	char name[21];
	int pl;
};
int main()
{
    int t;
    scanf("%d",&t);
    int pp=0;
    for(pp=0;pp<t;pp++){
    	int n;int i;
    	scanf("%d",&n);
    	struct student best[101];
    	for(i=0;i<n;i++){
    		scanf("%s %d",&best[i].name ,&best[i].pl );
		}
		int a[101];
		for(i=0;i<n;i++){
   		 	a[i]=best[i].pl;
    	}
    	int j,size=n;
		for(i=0;i<size-1;i++){
			int tempmin=i;
			for(j=i+1;j<size;j++){
				if(a[j]<a[tempmin]){
					tempmin=j;
				}
			}
			int tmp=a[i];
			a[i]=a[tempmin];
			a[tempmin]=tmp;
			int tmp1=best[i].pl ;
			best[i].pl =best[tempmin].pl ;
			best[tempmin].pl =tmp1;
			char temp2[21];
			strcpy(temp2,best[i].name );
			strcpy(best[i].name ,best[tempmin].name );
			strcpy(best[tempmin].name ,temp2);
		}
		for(i=n-1;i>=0;i--){
			printf("%s\n",best[i].name );
		}
	}
    return 0;
}