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

  • 相关阅读:
    MongoDB的简单操作
    MongoDB下载安装
    enctype="multipart/form-data" form表单提交值为null
    shiro
    json简单介绍
    Sql Server 安装
    MySQL面试常问的查询操作
    关于分页
    Vuex
    Vue基础安装(精华)
  • 原文地址:https://www.cnblogs.com/yzenet/p/2523565.html
Copyright © 2011-2022 走看看