好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C#实现输入10个数存入到数组中并求max和min及平均数的方法示例

本文实例讲述了C#实现输入10个数存入到数组中并求max和min及平均数的方法。分享给大家供大家参考,具体如下:

?

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

   class Program

   {

     static void Main( string [] args)

     {

       int nu1, max,min,number;

       int [] str = new int [10];

       for (nu1 = 0; nu1<10; nu1++)

         str[nu1] = Int32.Parse(Console.ReadLine());

       max = str[0];

       min = str[1];

       number = 0;

       for (nu1 = 0; nu1 < 10; nu1++)

       {

         number += str[nu1];

         if (str[nu1] > max)

           max = str[nu1];

         if (str[nu1] < min)

           min = str[nu1];

       }

         number /= 10;

       Console.WriteLine( "max is :{0}" ,max);

       Console.WriteLine( "min is :{0}" , min);

       Console.WriteLine( "pingjun is :{0}" , number);

       Console.ReadKey();

     }

   }

}

希望本文所述对大家C#程序设计有所帮助。

dy("nrwz");

查看更多关于C#实现输入10个数存入到数组中并求max和min及平均数的方法示例的详细内容...

  阅读:42次