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

#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;
}