Result: Accepted
Time: 4ms
Memory: 1120kB
#include <stdio.h>
#include <stdlib.h>
struct student{
char name[21];
int number;
};
int comp (const void*p,const void *q){
return ((struct student * )q )->number-((struct student * )p)->number;
}
int main (void){
struct student studentarry[101];
struct student number;
int t,n,i;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",studentarry[i].name,&studentarry[i].number);
}
qsort(studentarry,n,sizeof(struct student),comp);
for (i=0;i<n;i++){
printf("%s\n",studentarry[i].name);
}
}
return 0;
}