zoukankan      html  css  js  c++  java
  • 快速排序

        public static void quickSort(int[] array,int start,int end){
            int i = start;
            int j = end;
            int index = i+(int)((j-i)*Math.random());
    
            int tem = array[i];
            array[i] = array[index];
            array[index] = tem;
    
            int key = array[i];
            while(i < j ){
                while(i < j && key <= array[j]){
                    j--;
                }
                if(i < j){
                    int temp = array[j];
                    array[j] = array[i];
                    array[i] = temp;
                }
    
                while(i < j && key >= array[i]){
                    i++;
                }
                if(i < j){
                    int temp = array[j];
                    array[j] = array[i];
                    array[i] = temp;
                }
    
            }
    
            if(start < i){
                quickSort(array,start,i-1);
            }
            if(j < end){
                quickSort(array,j+1,end);
            }
    
        }
  • 相关阅读:
    Ado.net 02
    Ado.net01
    sql05
    sql04
    sql03
    sql02
    sql01
    czC#02
    czC#02
    Vue之render函数
  • 原文地址:https://www.cnblogs.com/cowshed/p/11397667.html
Copyright © 2011-2022 走看看