Start: Jan, 08, 2018 19:10:00
2017年秋季学期程序设计基础(C语言)期末考试
End: Jan, 08, 2018 21:40:00
Time elapsed:
Time remaining:

Problem_ID: E
Result: Accepted
Time: 721ms
Memory: 1716kB
In contest: 1139

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
struct stu {
	int total;
	string name;
}a[200];
int cmp(const void *a, const void *b) {
	return (*(struct stu *)b).total - (*(struct stu *)a).total;
}
int main() {
	int n, tempmark1, tempmark2, t;
	cin >> t;
	while (t--) {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> a[i].name >> tempmark1 >> tempmark2;
			a[i].total = tempmark1 + tempmark2;
		}
		qsort(a, n, sizeof(struct stu), cmp);
		for (int i = 0; i < n; i++) {
			cout << a[i].name << endl;
		}
	}
}