首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 输入十个数存入到数组中 并求max 和min 还有平均数

2013-03-16 
c# 输入10个数存入到数组中 并求max 和min 还有平均数using Systemusing System.Collections.Genericusi

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();        }    }}

热点排行