zoukankan      html  css  js  c++  java
  • 函数——数组排序

    namespace 函数冒泡排序
    {
        class Program
        {
         
            static void Main(string[] args)
            {
                int[] b = new int[5] { 1,5,3,4,2};

                new Program().Array(b);   //数组b调用已经写好的Array函数用来排序

                for (int i = 0; i < b.Length; i++)
                {
                    Console.WriteLine(b[i]);
                }
                Console.ReadLine();
               
            } //主函数的花括号

    //Array函数
            public int[] Array(int[] a)
            {  
                int n = a.Length;
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n-i; j++)
                    {
                        int temp=0;
                        if(a[j-1]<a[j])
                        {
                            temp = a[j - 1];
                            a[j - 1] = a[j];
                            a[j] = temp;
                        }
                    }
                }
                return a;
            }
        }
    }

  • 相关阅读:
    CentOS 7 使用NVM管理nodejs(转)
    Linux下Git安装及配置 (转)
    linux添加计划任务(转载)
    centos编译libcurl库找不到ssl的问题
    windows下搭建nginx+php+虚拟主机配置过程(转)
    xocde中宏定义使用
    unity shader vs高亮提示插件
    xcode8 自动打包
    3DMax中如何刷顶点色
    Adreno Profiler调试注意事项
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4420591.html
Copyright © 2011-2022 走看看