简单的冒泡排序
抽时间写下其他排序方法的
- #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;
- }