zoukankan      html  css  js  c++  java
  • 排序 冒泡排序法

    原文发布时间为:2009-03-06 —— 来源于本人的百度文章 [由搬家工具导入]

    using System;//冒泡排序

    namespace sorts
    {
       public class Class3
        {
           public static void Main()
           {
               int[] a=new int[]{2,8,4,6,9,4};
               BubbleSort arr=new BubbleSort();
               arr.Sort(a);
               for(int i=0;i<a.Length;i++)
                   Console.Write("{0} ",a[i]);
               Console.WriteLine();
               Console.ReadLine();
           }

        }
        public class BubbleSort
        {
            public void Sort(int[] arr)
            {
                for (int i = 0; i < arr.Length; i++)
                    for (int j = 0; j < arr.Length-i- 1; j++)
                    {
                        if (arr[j] > arr[j + 1])
                        {
                            int temp = arr[j + 1];
                            arr[j + 1] = arr[j];
                            arr[j] = temp;
                        }
                    }
            }
        }
    }

  • 相关阅读:
    I.MX6 Surfaceflinger 机制
    理解 Android Fragment
    RPi 2B DDNS 动态域名
    RPi 2B IPC webcam server
    理解 Android MVP 开发模式
    I.MX6 system.img unpack repack
    can't set android permissions
    VMware Ubuntu 共享文件夹
    解决oracle数据库连接不上的问题
    perfect-scrollbar示例
  • 原文地址:https://www.cnblogs.com/handboy/p/7153252.html
Copyright © 2011-2022 走看看