<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ~~~ package Sort; /** * 快速排序 1.當前數組拿到第一個數作為標準 * 2.從前往后,從后往前,兩個指針掃相對著往后掃描 當左往右的大于標準,右往左的小于標準,交換當右指針索引小于左指針,將當前右指針指向的數和標準進行交換 * 3.當前標準找到了正確位置,其他的數劃分成兩個子數組遞歸排序 * * 例 * 第一次交換 27 99(i) 0 8 13 64 86 16 7 10 88 25(j) 90 * 第二次交換 27 25 0 8 13 64(i) 8616 7 10(j) 88 99 90 * 第三次交換 27 25 0 8 13 10 86(i) 16 7(j) 64 88 99 90 * 第四次交換 27 25 0 8 13 10 7 16(j) 86(i) 64 88 99 90 * 劃分 16 25 0 8 13 10 7 27 86 64 88 99 90 * * @author lucky-freya * */ public class QuickSort { public int partition(int[]array,int startIndex,int endIndex){ int x = array[startIndex]; int i = startIndex + 1; int j = endIndex; while(true){ //判斷指針移位 while(i<= endIndex && array[i] <= x){ i++; } while(j>=0 && array[j]>x){ j--; } // 交換 if(i<j){ int swap = array[i]; array[i] = array[j]; array[j] = swap; }else{ return j; } } } public void quickSort(int[]array,int startIndex,int endIndex){ if (startIndex >= endIndex){ return; } int index = partition(array,startIndex,endIndex); //交換 int swap = array[startIndex]; array[startIndex] = array[index]; array[index] = swap; quickSort(array,startIndex,index - 1); quickSort(array,index + 1,endIndex); } public static void main(String args){ QuickSort sort = new QuickSort(); int[] array = new int[]{27,99,0,8,13,64,86,16,7,10,29,299}; sort.quickSort(array, 0, 11); for(int i = 0;i<array.length;i++){ System.out.println(array[i]); } } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看