[Sort]选择排序
2015-11-29 10:11
295 查看
详细介绍,在本博客的数据结构栏目里有,不过是java版
#include<iostream> using namespace std; void Select_Sort(int a[],int num) { for(int i=0;i<num-1;i++) { int x = i; //要选择的点的位置 for(int j = i+1;j<num;j++) { if(a[x] > a[j]) { //说明j更小 x = j; } } if(x != i) { int temp = a[i]; a[i] = a[x]; a[x] = temp; } } } void main() { int a[] = {57,68,59,52,72,28,96,33,24}; int count = sizeof(a) / sizeof(a[0]); Select_Sort(a,count); for(int i=0;i<count;i++) { cout<<a[i]<<" "; } cout<<endl; }
相关文章推荐
- SLIP 协议
- 我看Java虚拟机(3)---类文件结构
- Aptana简介与安装及其firebug的安装
- MySQL事务隔离级别详解
- hdu 1151 最小覆盖路径算法证明
- 在程序里设置加载网页
- 【cocos2dx】quick cocos2dx 3.5 节点层级太深就会就开始卡
- java基础随笔
- Human Motion Analysis: A Review理解
- 通用javascript代码判断版本号是否在版本范围之间
- java修饰符
- java 俄罗斯方块02
- 前端css编码规范
- [LeetCode]Binary Tree Paths
- C#开篇
- 探索软件智能高效自动化网络管理的规律
- Codeforces 598D Igor In the Museum(概率DP)
- 求助Syntax error, insert "}" to complete
- Win7\xp添加虚拟网Microsoft Loopback Adapter
- jQuery如何使用自动触发事件trigger