题解 | 字符串排序

字符串排序

https://www.nowcoder.com/practice/d2f088e655d44e4a85c16f7b99126211

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

int main() {
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i]>str[j]){
                char temp=str[i];
                str[i]=str[j];
                str[j]=temp;
            }
        }
    }
    cout<<str;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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