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