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

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

2015-04-29 10:24 211 查看
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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: