集册 Java实例教程 快速排序int数组

快速排序int数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

512
快速排序int数组


//package com.nowjava;


public class Main {/**来 自 时 代 J a v a 公 众 号**/


    public static void quicksort(int[] bb, int low, int high) {

        int w = 0;

        if (low < high) {

            w = split(bb, low, high, w);

            quicksort(bb, low, w - 1);

            quicksort(bb, w + 1, high);

        }

    }


    public static int split(int[] bb, int low, int high, int w) {

        int i = low;

        int x = bb[low];

        for (int j = low + 1; j <= high; j++) {

            if (bb[j] <= x) {

                i = i + 1;

                if (i != j) {
                /** 
                来 自 
                N o  w  J a v a . c o m - 时  代  Java
                **/

                    int temp = bb[i];

                    bb[i] = bb[j];

    
展开阅读全文