您的位置:首页 > 其它

图片排序

2016-07-27 18:25 218 查看
简单的冒泡排序

抽时间写下其他排序方法的

view
plaincopy
to clipboardprint?

#include<iostream>  

#include<string>  

#include<sstream>  

using namespace std;  

void main(){  

    string str;  

    getline(cin, str);  

    int N = str.size();  

    char temp;   

    for (int i = 0; i < N - 1; i++){  

        for (int j = 0; j < N - 1 - i; j++){  

            if (str[j]>str[j + 1]){  

                temp = str[j];  

                str[j] = str[j + 1];  

                str[j + 1] = temp;  

            }  

        }  

    }  

    cout << str;  

    //system("pause");  

    return;  

  

}  

view
plaincopy
to clipboardprint?

#include<iostream>  

#include<string>  

#include<algorithm>  

  

using namespace std;  

  

int main()  

{  

    string s;  

    cin>>s;  

    sort(s.begin(),s.end());  

    cout<<s<<endl;  

  

    return 0 ;  

}  

n = strlen(str);  

    sort( str, str + n ); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: