package suanfa;
public class kuaipai {
public static void main(String[] args) {
int a[] = { 0, 1, 8, 6, 5, 3, 2 };
int low = 0;
int high = a.length - 1;
sort(a, low, high);
for (int i = 1; i < a.length; i++)
System.out.print(a[i] + " ");
}
public static int paixu(int a[], int low, int high) {
a[0] = a[low];
while (low < high) {
while (low < high && a[high] >= a[0])
--high;
a[low] = a[high];
while (low < high && a[low] < a[0])
++low;
a[high] = a[low];
}
a[low] = a[0];
return low;
}
public static void sort(int a[], int low, int high) {
if (low < high) {
int pos = paixu(a, low, high);
sort(a, low, pos);
sort(a, pos + 1, high);
}
}
}