少年阿賓

          那些青春的歲月

            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 閱讀(382) 評論(0)  編輯  收藏 所屬分類: algorithm
          主站蜘蛛池模板: 灵石县| 清镇市| 邵阳县| 巴彦淖尔市| 阿图什市| 虹口区| 巴楚县| 山东省| 青海省| 张北县| 黎平县| 天峨县| 榆中县| 甘谷县| 和静县| 邯郸县| 洛南县| 三原县| 廉江市| 英山县| 镇康县| 汶川县| 曲阜市| 南京市| 安国市| 万州区| 莒南县| 景东| 都江堰市| 额尔古纳市| 马公市| 云梦县| 贵州省| 迁西县| 长泰县| 商丘市| 璧山县| 县级市| 威远县| 小金县| 上蔡县|