题解 | #小白鼠排队#

小白鼠排队

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

#include <bits/stdc++.h>
using namespace std;

typedef struct {
	int w;
	string hat;
}Shu; 

bool cmp(Shu a,Shu b){
	if(a.w > b.w)
		return true;
	else
		return false;
}

int main(){
	int n;
	Shu tmp;
	vector<Shu> shu;
	cin>>n;
	while(n--){
		cin>>tmp.w>>tmp.hat;
		shu.push_back(tmp);
	}
	sort(shu.begin(),shu.end(),cmp);
	for(int i = 0; i < shu.size(); i++)
		cout<<shu[i].hat<<endl;
}

全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务