zoukankan      html  css  js  c++  java
  • C#排序

     class Program
        {
            static void Main(string[] args)
            {

                int[] arr = new int[] { 49, 38, 65, 97, 76, 13, 27 };
                Sort(arr);
                for (int i = 0;  i < arr.Length; i++)
                {
                    Console.WriteLine("得到"+arr[i]);
                }
    }

    public static void Sort(int[] list)
            {
                int i, j, temp;
                bool done = false;
                j = 1;
                while((j<list.Length)&&(!done))
                {

                    done = true;
                    for (i = 0; i < list.Length - 1; i++)
                    {
                        if (list[i] > list[i + 1])  //0 1 ,1 2, 2,3 .......
                        {
                            done = false;
                            temp = list[i]; //替换
                            list[i] = list[i + 1];//替换
                            list[i + 1] = temp;//替换
                        }
                    }
                    j++; //自加
                }
            }

  • 相关阅读:
    python3.6 range() 函数
    常见文件头,文件尾总结。
    pycharm多行代码注释,或取消。
    php设计模式之命令模式
    php设计模式之工厂模式
    php设计模式之观察者模式
    SQLServer导出sql文件,导出表架构和数据
    vs2012建设网站,IIS8发布
    Subsonic 配置文件
    去掉txt中的重复标题
  • 原文地址:https://www.cnblogs.com/yzenet/p/2523565.html
Copyright © 2011-2022 走看看