public static void quickSort(int[] a, int l, int r){
if (l < r){
int i,j,x;
i = l;
j = r;
x = a[i];
while (i < j){
while(i < j && a[j] > x){
j--;
}
if (i<j){
a[i++] = a[j];
}
while (i < j && a[i] <x){
i ++;
}
if (i < j){
a[j--] = a[i];
}
} //end while
a[i] = x;
quickSort(a, l, i-1);
quickSort(a, i+1, r);
} //end if
}
网友评论