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

    原文发布时间为: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;
                }

            }

        }
    }

  • 相关阅读:
    npm包发布过程
    react树状组件
    js数据结构处理--------扁平化数组处理为树结构数据
    js数据结构处理--------树结构数据遍历
    JS fetch
    JS promise
    JS 闭包
    JS 异步回调
    三角形加正方形
    webAPI的分类
  • 原文地址:https://www.cnblogs.com/handboy/p/7153255.html
Copyright © 2011-2022 走看看