关于基础排序算法的思考--冒泡排序

冒泡排序基础

        static void Main(string[] args)
        {
            int[] a = { 3, 1, 5, 7, 2, 4, 9, 6 };

            for (int i = 0; i < a.Length - 1; i++)
            {
                for (int j = 0; j < a.Length - i - 1; j++)
                {
                    if (a[j] > a[j + 1])
                    {
                        int temp = a[j];
                        a[j] = a[j + 1];
                        a[j + 1] = temp;
                    }
                    for (int q = 0; q < a.Length; q++)
                    {
                        Console.WriteLine(a[q] + ",");
                    }
                }
            }

            for (int q = 0; q < a.Length; q++)
            {
                Console.WriteLine(a[q] + ",");
            }

        }
原文地址:https://www.cnblogs.com/livexiaojie/p/6704080.html