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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM