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

#include<stdio.h>
struct student {
	char name[21];
	int time;
};
int main() {
	struct student studentarray[101],x;
	int t, i,n;
	scanf("%d", &t);
	while (t--) { 
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%s%d", &studentarray[i].name, &studentarray[i].time);
		}
		for (i = 0; i < n - 1; i++) {
			for (int j = 0; j < n - 1 - i; j++) {
				if (studentarray[j].time < studentarray[j + 1].time) {
					x = studentarray[j]; 
					studentarray[j] = studentarray[j + 1]; 
					studentarray[j+1] = x;
				}
			}
		}
		for (i = 0; i < n; i++) {
			printf("%s\n", studentarray[i].name);
		}
	}
	return 0;
}