题解 | 小白鼠排队

小白鼠排队

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
struct mouse{
    string color;
    int weight;
};
int main() {
   int n;
   while(cin>>n){
        vector<mouse> mouses;
        for(int i=0;i<n;i++){
            mouse temp;
            cin>>temp.weight>>temp.color;
            mouses.push_back(temp);
        }
        sort(mouses.begin(),mouses.end(),[](mouse &a,mouse &b){
            return a.weight>b.weight;
        });
        for(mouse i:mouses) cout<<i.color<<endl;
   }
   return 0;
}

全部评论

相关推荐

牛客100866号技...:把电科加粗,把电科加粗,把电科加粗,两个吊车尾的项目合并成一个,再加一个管理系统。电科✌🏻在成都面中厂手拿把掐
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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