#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct Student
{
string name;
int score;
int age;
bool operator < (const Student &other) const
{
if (score != other.score) return score < other.score;
if (name != other.name) return name < other.name;
return age < other.age;
}
};
int main()
{
int n;
#ifndef ONLINE_JUDGE
ifstream cin("d:\\OJ\\uva_in.txt");
#endif
while (cin >> n) {
vector<Student> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].name >> v[i].age >> v[i].score;
}
sort(v.begin(), v.end());
for (size_t i = 0; i < v.size(); i++) {
cout << v[i].name << " " << v[i].age << " " << v[i].score << endl;
}
}
return 0;
}
题目1061:成绩排序
最新推荐文章于 2020-03-08 22:32:14 发布