using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
//数组的使用!
//遍历数组求平均分!
int[] fenshu = new int[] { 100, 300, 500, 800, 50 };
int Sun = 0;
for (int i = 0; i < fenshu.Length; i++)
{
Sun += fenshu[i];
}
int avg = Sun / fenshu.Length;
Console.WriteLine(avg);
//foreach 遍历数组;
foreach (var item in fenshu)
{
Sun += item;
}
int avgs = Sun / fenshu.Length;
Console.WriteLine(avg);
}
}
}
文章评论 本文章有个评论