题解 | #图片整理#__huawei_no.34-2

图片整理

https://www.nowcoder.com/practice/2de4127fda5e46858aa85d254af43941

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

int main() {
    string str;
    getline(cin, str);
    for (int i = 0; i < str.size(); i++) {
        for (int j = 0; j < str.size() - 1; j++) {
            if ( (str[j] ) > (str[j + 1])) {
                swap(str[j], str[j + 1]);
            }
        }
    }

    cout << str << endl;
    return 0;

}
// 64 位输出请用 printf("%lld")

直接冒泡排序来一波

全部评论

相关推荐

求过求过
xianwu543:华为不是线下面试吗?你怎么就面完了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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