C# 基础 计算平均值的方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace rmb
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] score = new int[] { 75, 65, 85, 85, 95, 65, 46, 46, 12, 46, 50, 125, 55, 66, 66, 99, 87, 89, 91, 95 };
            int sumscore = 0;
            foreach (var item in score)
            {
                sumscore += item;
            }
            int sumad = sumscore / score.Length;
            Console.WriteLine("平均成绩是{0}", sumad);
            Console.ReadKey();
        }
    }
}
原文地址:https://www.cnblogs.com/wordgao/p/4465213.html