zoukankan      html  css  js  c++  java
  • 插入排序

    import java.util.*;
    public class Insert{
        public void getInsert(int[] array){
            if(array == null || array.length == 0) return;
            int j=0;
            for(int i=1;i<array.length;i++){
                int temp = array[i];
                for(j=i;j>0&&(array[j-1]>temp);j--){
                    array[j]=array[j-1];
                }
                array[j] = temp;
            }
        }
        public static void main(String[] args){
            int[] array = {9,8,7,6,5,4,3,2,1};
            Insert i = new Insert();
            i.getInsert(array);
            System.out.println(Arrays.toString(array));
        }
    }
  • 相关阅读:
    英文词频统计
    字符串练习
    第八周
    第七周
    第五周
    第六周
    第三周
    第四周
    第二周
    第一周作业
  • 原文地址:https://www.cnblogs.com/yingpu/p/9266169.html
Copyright © 2011-2022 走看看