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;
                        }
                    }
            }
        }
    }

  • 相关阅读:
    manacher(求最大回文串并返回)
    编程求一个后缀表达式的值
    栈的简单使用
    云计算的概念
    乐优商城
    四大函数型接口
    Stream流计算
    JWT实现无状态登录
    Thymeleaf模板引擎
    elasticSearch的使用
  • 原文地址:https://www.cnblogs.com/handboy/p/7153252.html
Copyright © 2011-2022 走看看