少年阿賓

          那些青春的歲月

            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 閱讀(372) 評論(0)  編輯  收藏 所屬分類: algorithm
          主站蜘蛛池模板: 应城市| 民勤县| 城步| 衢州市| 邢台县| 承德县| 普格县| 乐清市| 林州市| 玛纳斯县| 抚州市| 宜良县| 土默特右旗| 自治县| 祥云县| 景宁| 鄂温| 乳源| 长顺县| 拉萨市| 西林县| 和平县| 溆浦县| 上高县| 文化| 犍为县| 石门县| 桦南县| 和静县| 东平县| 通州区| 枣庄市| 石嘴山市| 什邡市| 嘉义县| 东海县| 栾川县| 布尔津县| 淮北市| 安仁县| 肇庆市|