Java实现快速排序

public static void main(String[] args) {
        int[] nums = new int[]{2,3,4,5,1,3,4,5,7,8,24,56,45,75,98,12,34};
        quickSort(nums,0,nums.length-1);
        for(int i : nums){
            System.out.println(i);
        }

    }



    public static void quickSort(int[] nums,int left,int right){
        int i,j,temp,t;
        if(left>right){
            return;
        }
        i=left;
        j=right;
        //temp就是基准位
        temp = nums[left];

        while (i=nums[i]&&i

输出结果:

1
2
3
3
4
4
5
5
7
8
12
24
34
45
56
75
98

Process finished with exit code 0

 

你可能感兴趣的:(算法基础)