快速排序
2015-10-01 17:28
465 查看
@Test public void test5(){ int[] i = {25,4,5,7,18,21,23}; quickSort(i, 0 , i.length); System.out.println(Arrays.toString(i)); } private void quickSort(int[] array, int begin, int end){ int base = array[begin]; int index = begin; for (int i = begin; i < end; i++){ if (array[i] < base){ array[index] = array[index] ^ array[i]; array[i] = array[index] ^ array[i]; array[index] = array[index] ^ array[i]; index++; } } if(index > begin+1){ quickSort(array, begin, index); } if(index < end-1){ quickSort(array, index+1, end); } }
相关文章推荐
- C语言及程序设计.第二十三课.项目3.两段函数求值
- ThinkPHP控制器
- 黑马程序员——java学习笔记--正则表达式
- 关于Linux系统的平均负载最全面介绍
- 【点到线段距离】URAL - 1348 Goat in the Garden 2
- 无法关闭的QT程序(覆盖closeEvent,新建QProcess并脱离关系)
- 为arm内核构建源码树----Linux内核剖析(四)
- WINCC7.0下用户归档的查询与导出——导出篇
- linux块设备列表
- 微软提供了三个核心服务:Windows+Office 365+Azure
- 黑马程序员——抽象类,接口总结
- B/S测试与C/S测试区别
- Android进阶之“再按一次返回键退出程序”实现
- Ubuntu+Windows双系统重装Windows后修复Grub引导
- 黑马程序员——java学习笔记--字符串
- Android:Android2D绘图
- 文章标题
- 外网访问内网服务器设置方法+远程图形终端
- Permission is only granted to system apps的解决办法
- iOS开发-------多线程编程