少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            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 閱讀(388) 評論(0)  編輯  收藏 所屬分類: algorithm
          主站蜘蛛池模板: 隆回县| 哈密市| 浦城县| 宾川县| 广元市| 万荣县| 安塞县| 启东市| 隆子县| 乌兰察布市| 天台县| 通许县| 澄江县| 长顺县| 余庆县| 咸宁市| 南汇区| 万荣县| 伊吾县| 南充市| 浦城县| 房产| 佛学| 贺州市| 托克托县| 左权县| 旬邑县| 汨罗市| 兴海县| 长宁区| 尖扎县| 大宁县| 湘潭县| 芷江| 高要市| 景宁| 台湾省| 广饶县| 大渡口区| 清徐县| 阳泉市|