public class QuickSort {
public static void sort(int[] a, int low, int high){
if(low>=high){
return;
}
int low0 = low;
int high0 = high;
boolean forward = false;
while(low0!=high0){
if(a[low0]>a[high0]){
int temp = a[low0];
a[low0] = a[high0];
a[high0] = temp;
forward = !forward;
}
if(forward){
low0++;
}
else{
high0--;
}
}
low0--;
high0++;
sort(a, low, low0);
sort(a, high0, high);
}
public static void main(String[] args) {
int[] a = new int[]{6,8,3,5,9,0,1,2,4,7};
sort(a, 0, 9);
for(int i=0; i<a.length; i++){
System.out.print(a[i] + " ");
}
}
}
转载请注明来自:http://blog.csdn.net/sunxing007