救民于水火

x-hechengye 2022-08-09 16:00:06 16 返回题目

#include <bits/stdc++.h>
using namespace std;
struct rank {
    string id;
    double cj;
};
rank st[1001];
bool cmp(rank a, rank b) {
    if (a.cj != b.cj)
        return a.cj > b.cj;
    return a.id < b.id;
}
int main() {
    int n, k;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> st[i].id >> st[i].cj;
    }
    sort(st + 1, st + n + 1, cmp);
    for (int i = 1; i <= n; i++) {
        cout << st[i].id << ' ' << st[i].cj;
        cout << endl;
    }
    return 0;
}
{{ vote && vote.total.up }}