图片排序
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 );
抽时间写下其他排序方法的
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 );
相关文章推荐
- 富文本编辑器CKEDITOR使用注意事项,Ajax回调
- MQL5 命令行编译
- 资本寒冬,看咕咚、Keep、Feel们如何逆势而上
- Win8.1以及win10以上系统 安装msi文件方法
- [置顶] 有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student".
- Qt::ConnectionType 解析
- 矩阵基础1010 UVA 11651 矩阵快速幂+DP 好题,推荐
- 启动系统安装程序开发指定文件,安装应用
- Linphone探索:7 . 如何进行视频电话
- [docker]使用阿里云上面的私仓
- POJ-1258 Agri-Net 最小生成树(MST)
- Hadoop 日志文件分析
- poj 3295 Tautology && poj 1035 Spell checker 【字典树】
- DB2生成表model与mybatis的mapper中的常用方法
- springmvc组件总结
- NYOJ 269 VF
- 牛客网剑指offer刷题总结
- 工厂+单例模式
- QT国际化翻译的使用
- 常见的排序算法,Java实现