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