冒泡排序算法

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运行之后的结果:

学无止境,贵在积累
原文地址:https://www.cnblogs.com/izhaofu/p/4112987.html