Result: Accepted
Time: 3ms
Memory: 1120kB
#include<stdio.h>
#include<stdlib.h>
#define N 200
struct waihao{
char name[30];
int x;
};
int comp(const void *p,const void *q){
return ((struct waihao *)q)->x-((struct waihao *)p)->x;
}
int main(){
struct waihao a[N];
int x;
char name;
int t;
int i;
int b;
scanf("%d",&t);
while(t--){
scanf("%d",&b);
for(i=0;i<b;++i){
scanf("%s%d",a[i].name ,&a[i].x );
}
qsort(a,b,sizeof(struct waihao),comp);
for(i=0;i<b;++i){
printf("%s\n",a[i].name );
}
}
return 0;
}