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


     主程序入口

    class Program
        {
            static void Main(string[] args)
            {
                int[] iArrary = new int[] { 151361055992871234753347 };//定义数组
                BubbleSorter sh = new BubbleSorter();
                sh.Sort(iArrary);
                for (int m = 0; m < iArrary.Length; m++)//输出结果
                    Console.Write("{0} ", iArrary[m]);
                Console.ReadLine();
            }

        } 

    冒泡排序方法

     1  class BubbleSorter
     2     {
     3         /// <summary>
     4         /// 冒泡排序
     5         /// </summary>
     6         public void Sort(int[] list)
     7         {
     8             int i, j, temp;
     9             bool done = false;
    10             j = 1;
    11             while ((j < list.Length) && (!done))//判断长度
    12             {
    13                 done = true;
    14                 for (i = 0; i < list.Length - j; i++)
    15                 {
    16                     if (list[i] > list[i + 1])
    17                     {
    18                         done = false;
    19                         temp = list[i];
    20                         list[i] = list[i + 1];//交换数据
    21                         list[i + 1] = temp;
    22                     }
    23                 }
    24                 j++;
    25             }
    26         }

    27     } 

    乌龟才背着房子过一辈子
  • 相关阅读:
    zlog 使用手册
    Contribution and Coding Style Guide Bullet Physics Library
    Windows系统读写ext2/3/4文件系统的工具「ext2fsd」
    blender svn
    c# 各个版本
    c# Looping with the foreach statement
    C# 9.0 and .NET 5 – Modern Cross-Platform Development
    我的常用博客
    qml通过stacklayout实现页面切换
    JSON解析-android平台(转)
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083596.html
Copyright © 2011-2022 走看看