排序算法四:选择排序
2015-10-25 22:48
323 查看
static void SelectionSort(int[] array) { for (int i = 0; i < array.Length-1; i++) { int maxIndex = i; for(int j = i+1;j<array.Length;j++) { if(array[maxIndex] < array[j]) { maxIndex = j;//找到最大值所在下标 } } int temp = array[i]; array[i] = array[maxIndex]; array[maxIndex] = temp;//交换i、maxIndex的值 } }
相关文章推荐
- PyQt中弹出对话框操作
- 从头认识java-4.1 创建与初始化对象
- mac10.11+vim rust开发环境搭建
- 桥接模式(Bridge Pattern)
- 利用接口请求数据,以及JSON 解析请求下来的数据
- OpenCV GUI之搭建MFC+OpenCV开发环境
- VBScript随机数应用
- iOS 将时间戳转换为可读字符串
- 201510252245_《css——字间距》
- 大道至简第四张读后感
- DVR分布式路由
- XMPP客户端库Smack 4.1.4版官方开发文档之三
- android上使用opencv遇到的一点问题
- android Push 服务的消息
- jQuery插件 -- Cookie插件jquery.cookie.js(转)
- 九度OJ 1162:I Wanna Go Home(我想回家) (最短路径)
- QGraphicsTextItem中的文字对齐
- Killer Problem(暴力)
- 九度OJ 1162:I Wanna Go Home(我想回家) (最短路径)
- Ubuntu编译linux 1.2.13 内核