package helloclean.basetest;
import java.util.Scanner;
public class QuickSortTest {
int[] a = new int[101];
int n;
public void quickSort(int left, int right) {
int i, j, t, temp;
if(left > right) {
return;
}
temp = a[left];
i = left;
j = right;
while (i != j) {
while (a[j] >= temp && i < j) {
j --;
}
while (a[i] <= temp && i < j) {
i ++;
}
if(i < j) {
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
a[left] = a[i];
a[i] = temp;
quickSort(left, i - 1);
quickSort(i + 1, right);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
QuickSortTest quickSortTest = new QuickSortTest();
System.out.println("please input the length of the array:");
quickSortTest.n = scanner.nextInt();
for(int i = 1; i <= quickSortTest.n; i ++) {
System.out.println("please input the int vlaue:");
quickSortTest.a[i] = scanner.nextInt();
}
quickSortTest.quickSort(1,quickSortTest.n);
for(int i = 1; i <= quickSortTest.n; i ++){
System.out.print(quickSortTest.a[i] + " ");
}
System.out.println();
}
}