日期:2014-05-17  浏览次数:20850 次

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