您的位置:首页 > 编程语言 > C#

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

2013-03-13 21:40 387 查看
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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐