快速排序:
public static void main(String[] args) { int[] arr = new int[]{2,6,1,10,5,7,0,3}; quick(arr,0,arr.length-1); for(int i=0;i<arr.length;i++){ System.out.print(arr[i]+" "); } } public static void quick(int[] arr,int start,int end){ if(start<end){ int pivotkey = partition(arr,start,end); quick(arr,start,pivotkey-1); quick(arr,pivotkey+1,end); } } public static int partition(int[] arr,int start,int end){ int pivotkey = arr[start]; int low = start; int height = end; while(height>low){ while(height>low&&arr[height]>=pivotkey){ height--; } arr[low]=arr[height]; while(height>low&&arr[low]<=pivotkey){ low++; } arr[height]=arr[low]; } arr[height]=pivotkey; return height; }