题解 | #小白鼠排队#

小白鼠排队

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;
}

全部评论

相关推荐

码农顶针:估计让你免费辅导老板孩子的学习
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务