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

来源:互联网 发布:淘宝账号怎么注册不了 编辑:程序博客网 时间:2024/05/19 06:38

问题链接: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;}



原创粉丝点击