少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
          package com.abin.lee.algorithm.insert;
          import java.util.Arrays;
          public class InsertSort {
          public static void main(String[] args) {
          int[] input = {6,1,4,2,5,8,3,7,9,0};
          input = InsertSort.sort(input);
          System.out.println(Arrays.toString(input));
          }
          public static int[] sort(int[] input){
          int temp = 0;
          for(int i=0;i<input.length;i++){
          temp = input[i];
          int j=i-1;
          for(;j>=0&&temp<input[j];j--){
          input[j+1] = input[j];
          }
          input[j+1] = temp;
          }
          return input;
          }
          }
          posted on 2014-10-19 01:20 abin 閱讀(382) 評論(0)  編輯  收藏 所屬分類: algorithm
          主站蜘蛛池模板: 尚义县| 富裕县| 阿勒泰市| 会同县| 平定县| 巴楚县| 德阳市| 和顺县| 孟村| 武宁县| 凯里市| 农安县| 和硕县| 黑龙江省| 梁平县| 逊克县| 治县。| 茶陵县| 鲁山县| 泸水县| 军事| 都安| 桑植县| 张家界市| 忻城县| 松滋市| 辽阳县| 唐山市| 金昌市| 清新县| 定远县| 汽车| 宁化县| 沙雅县| 沁阳市| 三穗县| 建昌县| 上杭县| 扶风县| 旬阳县| 旅游|