冒泡排序算法

using System;
using System.Collections.Generic;

namespace LinQ
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            int temp;
            int[] sortArr = {12, 4, 25, 9, 105, 28, 95, 34, 54, 6, 49, 53, 67};
            for (int i = 0; i < sortArr.Length; i++)
            {
                for (int j = i + 1; j < sortArr.Length; j++)
                {
                    if (sortArr[j] < sortArr[i])
                    {
                        temp = sortArr[j];
                        sortArr[j] = sortArr[i];
                        sortArr[i] = temp;
                    }
                }
                Console.WriteLine(sortArr[i]);
            }
        }
    }
}

F5运行之后的结果:

posted @ 2014-11-21 15:05  月亮邮递员  阅读(240)  评论(0编辑  收藏  举报