import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] ints = new int[]{2,5,1,6,8,3,2,0,-3};
quickSort(ints, 0 , ints.length - 1);
System.out.println(Arrays.toString(ints));
}
public static void quickSort(int[] arr, int left, int right){
if (left >= right){
return;
}
int l = left;
int r = right;
while (l < r){
while (l < r && arr[r] >= arr[left]) r--;
while (l < r && arr[l] <= arr[left]) l++;
if (r == l){
int temp = arr[r];
arr[r] = arr[left];
arr[left] = temp;
} else {
int temp = arr[r];
arr[r] = arr[l];
arr[l] = temp;
}
}
quickSort(arr, left, l - 1);
quickSort(arr, r + 1, right);
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。