#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;
struct Student
{
int id;
int score;
bool operator < (const Student& other) const
{
if (score != other.score) return score < other.score;
return id < other.id;
}
};
Student stud[N];
int main()
{
int n;
#ifndef ONLINE_JUDGE
ifstream cin("d:\\OJ\\uva_in.txt");
#endif // ONLINE_JUDGE
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> stud[i].id >> stud[i].score;
}
sort(stud, stud + n);
for (int i = 0; i < n; i++) {
cout << stud[i].id << " " << stud[i].score << endl;
}
}
return 0;
}
题目1196:成绩排序
最新推荐文章于 2020-07-08 16:39:39 发布