作业1:
输入班级人数,然后依次输入学员成绩,计算班级学员的平均成绩和总成绩
static void Main(string[] args)
{
Console.WriteLine("请输入班级人数");
int count = Convert.ToInt32(Console.ReadLine());
int i = 0;
int sum = 0;
while (i<count)
{
Console.WriteLine("请输入第{0}个学员的成绩", i + 1);
int score = Convert.ToInt32(Console.ReadLine());
sum += score;
i++;
}
Console.WriteLine("{0}个学员的班级总分为{1},平均分为{2}", count, sum, sum / count);
Console.ReadKey();
}
网友评论