冒泡排序

        //冒泡排序

        private static void SortByMP()

        {

            int[] array = new int[] { 23, 33, 34, 143, 167, 278, 179, 108 };

            int temp;

            for (int i = 0; i < array.Length; i++)

            {

                for (int j = i + 1; j < array.Length; j++)

                {

                    if (array[i] > array[j])

                    {

                        temp = array[i];

                        array[i] = array[j];

                        array[j] = temp;

                    }

                }

            }

            for (int i = 0; i < array.Length; i++)

            {

                Console.WriteLine(array[i]);

            }

        }

 

你可能感兴趣的:(冒泡排序)