• 冒泡排序 C#


    static void Main(string[] args)
            {
                int[] nums = { 5, 10, 3,8,20,7};
                Console.WriteLine("数组长度:"+nums.Length);
                for (int i = 0; i < nums.Length; i++)  //外层循环,控制次数
                {
                    for (int j = 0; j < nums.Length-i-1; j++) //内层循环,相临2个数比较
                    {
                        int temp;
                        if (nums[j] > nums[j + 1])
                        {
                            temp = nums[j + 1];
                            nums[j + 1] = nums[j];
                            nums[j] = temp;
                        }
                    }
                }
                for (int i = 0; i < nums.Length; i++)
                {
                    Console.WriteLine(nums[i]);
                }
                Console.ReadKey();
            }

  • 相关阅读:
    SwiftUI:看我展示52张扑克牌,“很快啊!”
    不会吧,这也行?iOS后台锁屏监听摇一摇
    分布式锁
    布隆过滤器原理
    redis缓存穿透
    布隆过滤器应用DEMO
    线程的声明周期
    分布式事务
    滑动窗口协议
    代理
  • 原文地址:https://www.cnblogs.com/HarryChis/p/13737294.html
Copyright © 2020-2023  润新知