zoukankan      html  css  js  c++  java
  • C# foreach,等量代换,冒泡排序

    foreach:


            foreach (int h in a) //可以将数组读出来(自动遍历数组)
                    {
                        Console.WriteLine(h);
                    }

    等量代换: 用一种量(或一种量的一部分)来代替和它相等的另一种量(或另一种量的一部分)。

     

                //需要有个中间变量来倒
                int a = 3, b = 5;
                int c;
                c = a;
                a = b;
                b = a;

    冒泡排序

                int[] shu = new int[10];
                for (int i = 0; i < 10; i++)
                {
                    shu[10] = Convert.ToInt32(Console.ReadLine());
                }
                for (int j = 0; j < 10 - 1; j++)
                {
                    for (int i = j; i < 10; i++)
                    {
                        if (shu[j] < shu[i])
                        {
                            int zhong = 0;
                            shu[i] = shu[j];
                            shu[j] = zhong;
                        }
                    }
                }

  • 相关阅读:
    Debian7安装msf
    Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站
    五、docker配置镜像加速器之阿里云
    四、harbor实践之初识harbor
    三、harbor部署之SSL
    二、harbor部署之部署harbor
    超级强悍的PHP代码编辑器PHPstorm及配置
    PHP使用DomDocument抓取HTML内容
    37条常用Linux Shell命令组合
    PHP常用数组函数
  • 原文地址:https://www.cnblogs.com/2041388565m/p/4165204.html
Copyright © 2011-2022 走看看