题解 | #小白鼠排队#

小白鼠排队

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

全部评论

相关推荐

08-22 11:25
已编辑
南京财经大学 Java
程序员小白条:优先背八股文,JUC,JVM这些基础概念一定要会,spring底层先放放,408也是八股优先,不考研,不用深入去学,没性价比,多搞搞算法,起码两个题单熟练刷,起码300-400题的精刷
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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