HDU2000 ASCII码排序【字符串排序】

问题链接HDU2000 ASCII码排序

问题简述:参见上述链接

问题分析

这个问题几乎没有技术含量,原意是作为C语言程序的练习。

然而,如果用C++语言来编写程序,需要用到哪些技术呢?看了程序才能知道。

程序说明(略)

题记杀鸡也用宰牛刀。


AC的C++语言程序如下:

/* HDU2000 ASCII码排序 */

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

const int N = 3;

int main()
{
    string s;

    while(getline(cin, s)) {
        sort(s.begin(), s.end());

        for(int i=0; i<N; i++) {
            if(i != 0)
                cout << " ";
            cout << s[i];
        }
        cout << endl;
    }
    return 0;
}



原文地址:https://www.cnblogs.com/tigerisland/p/7563731.html