zoukankan      html  css  js  c++  java
  • Bubble Sort

    最简单的排序方式,实现如下:

    代码
            /// <summary>
            
    /// 冒泡排序
            
    /// </summary>
            
    /// <param name="data"></param>
            public static void BubbleSort(int[] data)
            {
                
    if (data == null || data.Length < 1)
                {
                    
    throw new ArgumentNullException("data");
                }

                
    int temp;
                
    int index = data.Length - 1;
                
    while (index > 0)
                {
                    
    for (int i = 0; i < index; i++)
                    {
                        
    if (data[i] > data[i + 1])
                        {
                            temp 
    = data[i];
                            data[i] 
    = data[i + 1];
                            data[i 
    + 1= temp;
                        }
                    }

                    
    --index;
                }
            }
  • 相关阅读:
    程序经理_产品经理_项目经理
    github上排名靠前的java项目之_storm
    垂直型与水平型电子商务网站的理解
    关于驱动更新的一点学习
    Balanced Binary Tree
    Gray Code
    Best Time to Buy and Sell Stock II
    Best Time to Buy and Sell Stock
    Maximum Depth of Binary Tree
    Next Permutation
  • 原文地址:https://www.cnblogs.com/Langzi127/p/1691822.html
Copyright © 2011-2022 走看看