题解 | #小白鼠排队#

小白鼠排队

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

#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct Mouse{
    int weight;
    string color;
}a[105];
bool comp(Mouse a,Mouse b){
    return a.weight>b.weight;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>a[i].weight>>a[i].color;
    }
    sort(a,a+n,comp);
    for(int i=0;i<n;i++){
        printf("%s\n",a[i].color.c_str());
    }
    return 0;
}

全部评论

相关推荐

头像
05-12 09:14
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务