题解 | #小白鼠排队#

小白鼠排队

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

#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

struct smallMouse{
    int weight;
    char color[20];
};

bool Comp(smallMouse a,smallMouse b){
    return a.weight > b.weight;
};

int main() {
    int N;
    smallMouse smouse[100];
    while(scanf("%d",&N) != EOF){
        for (int i = 0; i < N; ++i) {
            scanf("%d %s",&smouse[i].weight,smouse[i].color);
        }
        sort(smouse, smouse+N,Comp);
        for (int j = 0; j < N; ++j) {
            printf("%s\n",smouse[j].color);
        }
    }
}

全部评论

相关推荐

下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
喜欢飞来飞去的雪碧在...:可以试一试字节
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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