冒泡排序

        //冒泡排序
        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]);
            }
        }

 

posted @ 2013-07-31 16:39  --宁静以致远--  阅读(156)  评论(0)    收藏  举报