zoukankan      html  css  js  c++  java
  • [原创]选择排序SelectSort Virus

    class Program
        {
            static void Main(string[] args)
            {
                SelectSort select = new SelectSort();
                select.Start();
                select.Display();
                Console.ReadLine();
            }
        }

    class SelectSort
        {
            private int[] mylist;

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

            public void Start()
            {
                int temp=0;
                for (int i = 0; i < mylist.Length; i++)
                {
                    int k = i;
                    for (int j = i + 1; j < mylist.Length; j++)
                    {
                        if (mylist[j] < mylist[k])
                        {
                            k = j;
                        }
                    }
                    if (k != i)
                    {
                        temp = mylist[k];
                        mylist[k] = mylist[i];
                        mylist[i] = temp;
                    }
                }
            }

            public void Display()
            {
                for (int i = 0; i < mylist.Length; i++)
                {
                    Console.WriteLine(mylist[i].ToString());
                }
            }
        }

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

    【MSN】jorden008@hotmail.com

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

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

  • 相关阅读:
    python json 和 pickle的补充 hashlib configparser logging
    go 流程语句 if goto for swich
    go array slice map make new操作
    go 基础
    块级元素 行内元素 空元素
    咽炎就医用药(慢性肥厚性咽炎)
    春季感冒是风寒还是风热(转的文章)
    秋季感冒 咳嗽 怎么选药
    解决IE浏览器“无法显示此网页”的问题
    常用的 css 样式 记录
  • 原文地址:https://www.cnblogs.com/virusswb/p/852531.html
Copyright © 2011-2022 走看看