zoukankan      html  css  js  c++  java
  • Bubble Sort (c#)

            static void Main(string[] args)
            {
                int[] array = { 23, 45, 16, 7, 42,100,2 };
                int length = array.Length - 1;
                bool isExchanged = false;
                for (int i = 0; i < length; i++)
                {
                    for (int j = length; j > i; j--)
                    {
                        if (array[j]< array[j - 1])
                        {
                            int temp = array[j];
                            array[j] = array[j - 1];
                            array[j - 1] = temp;
                            isExchanged = true;
                        }
                    }
                    if (!isExchanged)
                        break;
                }
                foreach (int i in array)
                {
                    Console.WriteLine(i);
                } Console.Read();
            }

  • 相关阅读:
    蓝牙低功耗(Bluetooth Low Energy)
    Android 蓝牙(概述)
    Android 学习笔记之 Activity 简介
    Android 学习笔记之常用控件
    Android 学习笔记之界面布局
    委托和事件(C#)
    Java 资源汇总
    如何阅读英文原版教材
    Combobox 控件绑定数据
    《将博客搬至CSDN》
  • 原文地址:https://www.cnblogs.com/select/p/2139546.html
Copyright © 2011-2022 走看看