快速排序
来源:互联网 发布:苹果手机下载不了淘宝 编辑:程序博客网 时间:2024/06/05 11:01
快速排序
public class Test {public static void main(String[] args) {int[] a = { 12, 3, 4, 5, 2, 65, 43, 23 };fastsort(a, 0, a.length - 1);for(int i =0 ; i<a.length;i++)System.out.print(a[i]+",");System.out.println();}private static void fastsort(int[] a, int low, int high) {if (low >= high)return;int loc = loc(a, low, high);fastsort(a, low, loc-1);fastsort(a, loc + 1, high);}private static int loc(int[] a, int low, int high) {int flag = a[low];while (low < high) {while (low < high && a[high] > flag) {high--;}if (low < high) {a[low++] = a[high];}while (low < high && a[low] <= flag) {low++;}if (low < high) {a[high--] = a[low];}a[low] = flag;}return low;}}
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- STL剖析电梯
- 一步步教你为网站开发Android客户端
- 【Python】 sorted函数
- 初入android开发之项目开发框架
- velocity使用工具类
- 快速排序
- Jsp之指令元素(page)
- 申请域名
- hibernate入门实例
- poj2909 Goldbach's Conjecture
- 馨瑶
- 【Unity3d】关于打APK包勾选DevelopmentBuild摄像机正常,不勾则不正常问题
- c++ 字符串常量
- [Leetcode]Two Sum II - Input array is sorted