题解 | #小白鼠排队#

小白鼠排队

https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b

#include<cstdio>
#include<algorithm>
using namespace std;
struct mouse{
	int weight;
	char colour[10];
};
bool comp(mouse lhs, mouse rhs){
	if (lhs.weight > rhs.weight){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	int n;
	mouse s[100];
	while (scanf("%d", &n) != EOF){
		for (int i = 0; i < n; i++){
			scanf("%d %s", &s[i].weight, &s[i].colour);
		}
		sort(s, s + n, comp);
		for (int i = 0; i < n; i++){
			printf("%s\n", s[i].colour);
		}
	}
}

全部评论

相关推荐

06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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