static void Main(string[] args)
{/**
* 输入班级人数,然后依次输入学员成绩,计算班级学员的平均成绩和总成绩
* */
Console.WriteLine("请输入班级人数");
string renshu = Console.ReadLine();
int people = Convert.ToInt32(renshu);
int i = 0; //定义 班级人数
int sum = 0; //定义 他们的总成绩
while (i < people)
{
Console.WriteLine("请输入第{0}个学员的成绩",i+1);
try
{
string mougexueyuanchengji = Console.ReadLine();
int daomougexueyuanweizhidezongchengji = Convert.ToInt32(mougexueyuanchengji);
sum += daomougexueyuanweizhidezongchengji; //sum=sum+daomougexueyuanweizhidezongchengji
i++; // 人数一直累加 即为 人数+1 +1 +1 一直加1
}
catch
{
Console.WriteLine("输入有误,请重新输入");
}
Console.WriteLine("{0}个人的班总成绩是{1},平均成绩是{2}", i, sum, sum/i );
}
Console.ReadKey();