题解 | #小白鼠排队#自定义CMP
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include <bits/stdc++.h>
using namespace std;
struct Mouse{
int weight;
string color;
}mouse[110];
bool cmp(Mouse m1,Mouse m2){
return m1.weight > m2.weight;
}
int main(){
int n;
cin >> n;
for(int i = 0;i < n;i ++)cin >> mouse[i].weight >> mouse[i].color;
sort(mouse,mouse + n,cmp);
for(int i= 0;i < n;i ++)cout << mouse[i].color << endl;
return 0;
}
正浩创新EcoFlow公司福利 510人发布
