题解 | #小白鼠排队#

小白鼠排队

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

#include<cstdio>
#include<algorithm>

using namespace std;

struct Mouce{
    int weight;
    char color[100];
};

bool comp(Mouce lhs ,Mouce rhs){
    if(lhs.weight > rhs.weight){
        return true;
    }
    else{
        return false;
    }
}
int main(){
    int n;
    Mouce arr[101];
    while(scanf("%d",&n)!=EOF){
        for(int i = 0 ; i < n ;++i){
            scanf("%d %s\n",&arr[i].weight,arr[i].color);
        }
        sort(arr,arr+n,comp);
        for(int i = 0 ; i < n ; ++ i ){
        printf("%s\n",arr[i].color);
        }
    }
}

全部评论

相关推荐

Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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