多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[https://www.jianshu.com/p/c1a05c50a75c](https://www.jianshu.com/p/c1a05c50a75c) ~~~ // 快速排序法 public class Algorithm0004 { public static void main(String[] args) { int[] nums = new int[]{8, 500, 22, 3, 1000, 5, 999, 10, 88, 7}; sort(nums, 0, nums.length - 1); for (int i = 0; i < nums.length; i++) { System.out.println(nums[i]); } } private static void sort(int[] nums, int begin, int end) { if (begin > end) { return; } int base = nums[begin]; int i = begin; int j = end; while (j != i) { while (nums[j] >= base && j > i) { j--; } while (nums[i] <= base && i < j) { i++; } if (j > i) { // 交换位置 int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } } nums[begin] = nums[i]; nums[i] = base; sort(nums, begin, i - 1); sort(nums, i + 1, end); } } ~~~