码迷,mamicode.com
首页 > 其他好文 > 详细

冒泡排序

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

标签:io   for   ar   line   new   ad   数组   c   

#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

冒泡排序

标签:io   for   ar   line   new   ad   数组   c   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!