import java.util.Arrays;
public class 快速排序 {
static int[] array = new int[]{5,2,7,-2,9,0,-9};
public static void main(String[] args) {
quickSort(array,0,array.length -1);
}
private static void quickSort(int[] array, int start, int end) {
if(start < end){
int base = array[start];
int i = start;
int j = end + 1;
while(true){
while(i <end && array[++i] <= base);
while(j > start && array[--j] >= base);
if(i <j){
int a = array[i];
array[i] = array[j];
array[j] = a;
System.out.println(Arrays.toString(array));
}else{
break;
}
}
int a = array[start];
array[start] = array[j];
array[j] = a;
System.out.println(Arrays.toString(array));
quickSort(array,start,j-1);
quickSort(array,j+1,end);
}
}
}