zoukankan      html  css  js  c++  java
  • 冒泡排序大比拼看看谁的算法最简单

    一.

    ///////////////////////////////////////////////////////////////////////////////

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {

                int[] a = { 3, 4, 7, 10, 5, 9 };
                int[] b = BubbleSort(a);
                for (int i = 0; i < b.Length; i++)
                {
                    Console.Write(b[i].ToString() + " ");

                }
                Console.ReadLine();
            }

            public static int[] BubbleSort(int[] list)
            {
                int i, temp;
                for (int j = 0; j < list.Length; j++)
                {
                    for (i = list.Length - 1; i > j; i--)
                    {
                        if (list[j] < list[i])
                        {
                            temp = list[j];
                            list[j] = list[i];
                            list[i] = temp;
                        }
                    }
                }

                return list;
            }
        }
    }

    二.

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    static void Main(string[] args)
            {

               
    int[] a = { 3, 4, 7, 10, 5, 9 };
                Array.Sort(a);
               
    for (int i = 0; i < b.Length; i++)
                {
                    Console.Write(b[i].ToString()
    + " ");

                }
                Console.ReadLine();
            }


       本人博客的文章大部分来自网络转载,因为时间的关系,没有写明转载出处和作者。所以在些郑重的说明:文章只限交流,版权归作者。谢谢

  • 相关阅读:
    P1829 [国家集训队]Crash的数字表格 / JZPTAB 莫比乌斯反演
    Luogu P1447 [NOI2010]能量采集 数论??欧拉
    Luogu P2522 [HAOI2011]Problem b 莫比乌斯反演
    Luogu P2257 YY的GCD 莫比乌斯反演
    [笔记] 数论函数小记
    [笔记] 线性筛小记
    Luogu P1092 虫食算 爆搜
    Luogu P1066 2^k进制数 组合数学
    Luogu P1641 [SCOI2010]生成字符串 组合数学
    Luogu P2532 [AHOI2012]树屋阶梯 卡特兰数
  • 原文地址:https://www.cnblogs.com/wzg0319/p/1630560.html
Copyright © 2011-2022 走看看