首页 > 其他 > 详细

冒泡排序

时间:2014-07-31 09:44:06      阅读:354      评论:0      收藏:0      [点我收藏+]

#region  数组 最大值 最小值 平均值 求和 冒泡排序        

     int[] arrag = new int[5] { 31, 62, 83, 54, 85 };             for (int i = 0; i < 5; i++)             {                 for (int j = i + 1; j < 5; j++)                 {                     if (arrag[i] > arrag[j])                     {

                        int myarrag;                         myarrag = arrag[i];                         arrag[i] = arrag[j];                         arrag[j] = myarrag;                     }                 }                 Console.Write(arrag[i]);             }             Console.ReadKey();             //    int sum = 0;             //    int min;             //    int max;             //    max = arrag[0];             //    min = arrag[arrag.Length - 1];             //    Console.Write(max + "\n");             //    Console.Write(min + "\n");             //    for (int i = 0; i < 5; i++)             //    {             //        sum += arrag[i];             //    }             //    Console.WriteLine(sum);             //    int avg;             //    avg = sum / arrag.Length;             //    Console.WriteLine(avg);             //    for (int i = 0; i < 5; i++)             //    {             //        Console.WriteLine(arrag[i]);             //    }

            //    Console.ReadKey();             #endregion

冒泡排序,布布扣,bubuko.com

冒泡排序

原文:http://www.cnblogs.com/huweijun/p/3879933.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!