【快速排序】

public static void sort(int[] a, int low, int high){
        int i = low, j = high;
        if(i < 0 || i > j)   return;
        int k = a[i];
        while(i < j){
            while(i < j && a[j] > k) j--;
            while(i < j && a[i] <= k) i++;
            if(i < j){
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        k = a[i];
        a[i] = a[low];
        a[low] = k;

        sort(a, low, i - 1);
        sort(a, i - 1, high);
    }

你可能感兴趣的:(【快速排序】)