zoukankan      html  css  js  c++  java
  • [原创]直接插入排序InsertSort Virus

     class InsertSort
        {
            private int[] mylist;

            public InsertSort()
            {
                mylist = new int[] {  19, 13, 5, 27, 1, 26, 31, 16, 2, 9, 11, 21 } ;
            }

            public void Start()
            {
                int T;
                for (int j =1; j < mylist.Length; j++)
                {
                    T = mylist[j];
                    int i = j - 1;
                    while (i>=0 && mylist[i]>T)
                    {
                        mylist[i+1]=mylist[i];
                        i=i-1;
                    }
                    mylist[i + 1] = T;
                }
            }

            public void Display()
            {
                for (int i = 0; i < mylist.Length - 1; i++)
                {
                    Console.WriteLine(mylist[i].ToString());
                }
            }
        }
    class Program
        {
            static void Main(string[] args)
            {
                InsertSort insert = new InsertSort();
                insert.Start();
                insert.Display();
                Console.ReadLine();
            }
        }

    【Blog】http://virusswb.cnblogs.com/

    【MSN】jorden008@hotmail.com

    【说明】转载请标明出处,谢谢

    反馈文章质量,你可以通过快速通道评论:

  • 相关阅读:
    快速排序(java实现)
    java8 stream一些知识
    Lombok安装、简单使用、入门
    explain mysql 结果分析
    MySQL调优三部曲(二)EXPLAIN
    MySQL调优三部曲(一)慢查询
    排查问题
    Dynamics 365 获取值 设置值
    MySql CP 表 和 数据
    Dynamics 365单项选项集&多项选项集
  • 原文地址:https://www.cnblogs.com/virusswb/p/852523.html
Copyright © 2011-2022 走看看