只是这个地方写反了。
写成大于等于也可以,写成等于就报错。
import java.util.Arrays;
public class quickSort22 {
public static void main(String[] args) {
int a[]={7,6,4,2,99,-32,-3232,23232,32,9,1,22,3,1};
quickSort(a,0,a.length-1);
System.out.println(Arrays.toString(a));
}
public static void quickSort(int a[] , int low , int high){
if(low>high)
return;
int mid = part(a,low,high);
quickSort(a,low,mid-1);
quickSort(a,mid+1,high);
}
public static int part(int a[] , int low ,int high){
int pivot = a[low];
while(low<high){
while(low<high && a[high]>=pivot)
high--;
a[low] = a[high];
while(low<high && a[low]<=pivot)
low++;
a[high] = a[low];
}
a[low] = pivot;
return low;
}
}
标签:int,quickSort,high,static,low,排序,快速,public,霸气 From: https://www.cnblogs.com/cs-lcy/p/17472573.html