本文共 684 字,大约阅读时间需要 2 分钟。
package paixu;import org.junit.Test;import java.util.Arrays;public class KuaiSu {    public int getMiddle(int[] arr, int low, int high){        int temp = arr[low];//选取中轴值        while(low       =temp){                high--;            }            arr[low] = arr[high];//比中轴小的移到左侧低端            while (low < high && arr[low]<=temp){                low++;            }            arr[high] = arr[low];//比中轴大的移到右侧高端        }        arr[low] = temp;//把中轴放在大小交界处。        return low;//返回中轴位置    }    public void quickSort(int[] arr, int low, int high){        if(low          0) {            quickSort(arr,0,arr.length-1);        }        System.out.println(Arrays.toString(arr));    }}            
转载地址:http://tyqwz.baihongyu.com/