清华大学机试 成绩排序 Easy
基本思想:
无;
关键点:
无;
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<set> #include<map> using namespace std; struct node { int p; int q; }; node ma[110]; bool cmp(node a, node b) { if (a.q != b.q) { return a.q < b.q; } if (a.q == b.q) return a.p < b.p; } int main() { int n; while (cin>>n){ for (int i = 0; i < n; i++) { cin >> ma[i].p >> ma[i].q; } sort(ma, ma + n, cmp); for (int i = 0; i < n; i++) cout << ma[i].p << " " << ma[i].q << endl; } return 0; }

浙公网安备 33010602011771号