冒泡排序

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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[5]{2,1,3,4,5};
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = i + 1; j < array.Length; j++)
                {
                    if (array[j] < array[i])
                    {
                        int temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                    }
                }
            }
            foreach (int n in array)
            
            Console.WriteLine(n);
            Console.ReadLine();
        }
    }
}

  

posted on 2016-02-19 09:19  第三轮旭  阅读(195)  评论(0编辑  收藏  举报

导航