先看代码
public static void quicksort(int[]a,int left,int right){ int i = left; int j = right; int temp=a[left]; int t = 0; while(i!=j){ while(a[j]>=temp && i<j){ j--; } while(a[i]<=temp && i<j){ i++; } if(i<j){ t = a[i]; a[i] = a[j]; a[j] = t; } } a[left] = a[i]; a[i] = temp; quicksort(a, left, i-1); quicksort(a, i+1, right); }