题解 | #小白鼠排队#
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include <iostream> #include <algorithm> #include <string> using namespace std; const int MAXN = 100; struct mouse { int weight; string color; }; bool Compare (mouse x, mouse y){ return x.weight > y.weight; } int main () { int n; cin >> n; mouse mos[MAXN]; for (int i = 0; i < n; i++){ cin >> mos[i].weight >> mos[i].color; } sort (mos, mos + n, Compare); for (int i = 0; i < n; i++){ cout << mos[i].color << endl; } return 0; }