码迷,mamicode.com
首页 > 编程语言 > 详细

插入排序

时间:2017-12-30 22:35:15      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:++   stat   color   class   排序   i++   插入   style   span   

 

    public static int[] InsertSort(int[] arr) {
        for(int i=1;i<arr.length;i++){
            int temp = arr[i];
            int j;
            for(j=i-1;j>=0 && temp < arr[j];j--){
                arr[j+1] = arr[j];
            }
            arr[j+1] = temp;
        }
        return arr;
    }

 

插入排序

标签:++   stat   color   class   排序   i++   插入   style   span   

原文地址:https://www.cnblogs.com/weishao-lsv/p/8151274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!