package java面试宝典;
import java.util.Arrays;
public class 快速排序 {
public static void main(String[] args) {
int[] a={6,9,3,5,7,1,8,0,2,4};
System.out.println(Arrays.toString(a));
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 i=low;
int j=high;
int temp=a[low];
while(i<j){
while(i<j&&a[j]>temp){
j--;
}
if(i<j){
a[i]=a[j];
}
while(i<j&&a[i]<=temp){
i++;
}
if(i<j){
a[j]=a[i];
}
}
a[j]=temp;
quickSort(a, low, j-1);
quickSort(a, j+1, high);
}
}