//计算五位学生的平均分,五位学生的成绩分别为:60 80 90 70 85
try { int[] scores = new int[5];//成绩数组
int sum = 0;//成绩总和
Console.WriteLine("请输入5位学员的成绩:");
for (int i = 0; i < scores.Length; i++)
{
scores[i] = Convert.ToInt32(Console.ReadLine());
sum = sum + scores[i];//成绩累加
}
Console.WriteLine("平均分是:"+(double)sum/scores.Length);
}
catch
{ Console.WriteLine("输入格式错误");
}
Console.ReadKey();