首页 > 编程语言 > 详细

排序 普通插入法排序

时间:2017-07-12 09:32:22      阅读:167      评论:0      收藏:0      [点我收藏+]

原文发布时间为:2009-03-06 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
//using System.Collections.Generic;
//using System.Text;

namespace sorts
{
    public class Class2//插入法排序
    {
        public static void Main()
        {
            int[] iArrary = new int[] { 1, 5, 3, 6, 10, 3, 9 };
            Sort(iArrary);
            for (int m = 0; m < iArrary.Length; m++)
                Console.Write("{0} ", iArrary[m]);
            Console.ReadLine();
        }
        public static void Sort(int[] list)
        {
            for (int i = 1; i < list.Length; ++i)
            {
                int t = list[i];
                int j = i;

                while ((j > 0) && (list[j - 1] > t))
                {
                    list[j] = list[j - 1];
                    --j;
                }
                list[j] = t;
            }

        }

    }
}

排序 普通插入法排序

原文:http://www.cnblogs.com/handboy/p/7153255.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!