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++; //自加
                }
            }

  • 相关阅读:
    mysql应用技巧
    Python httplib学习
    桌标相关知识
    行业百科知识--Github
    Ghost win7 系统安装(虚拟机)
    记一次pycharm和vscode因网络问题插件下载失败的问题
    Pydiction补全插件
    MS17-010远程溢出漏洞(CVE-2017-0143)
    shell快速入门
    Yarn架构
  • 原文地址:https://www.cnblogs.com/yzenet/p/2523565.html
Copyright © 2011-2022 走看看