首页 > 代码库 > 练习2014102201

练习2014102201

/********************************************************************@date     2014-9-25@author   Tiger@brief    算法@details  冒泡排序********************************************************************/using System;class Demo{    static void Main()    {        int[] arr = new int[] { 3, 7, 6, 5 };        int nTemp = 0;        for (int i = 1; i < arr.Length; ++i)        {            bool bFlag = false;            for (int j = 0; j < arr.Length - 1; ++j)            {                if (arr[j] > arr[j + 1])                {                    nTemp = arr[j];                    arr[j] = arr[j + 1];                    arr[j + 1] = nTemp;                    bFlag = true;                }            }            if (!bFlag)            {                break;            }        }        for (int i = 0; i < arr.Length; ++i)        {            Console.WriteLine(arr[i]);        }        Console.ReadLine();    }}

 

练习2014102201