2018-11-08作业1

2018-11-08  本文已影响0人  大长腿快快跑

输入班级人数,然后依次输入学员成绩,计算班级学员的平均成绩和总成绩

         Console.WriteLine("请输入班级人数:");
        int people =Convert .ToInt32 ( Console.ReadLine());
        int i = 0;
        int sum = 0;
        while (i < people)
        {
            Console.WriteLine("请输入第{0}个人的成绩",i+1);
            int score = Convert.ToInt32(Console.ReadLine());
            sum += score;
            i++;
        }
        Console .WriteLine ("总成绩为{0},平均成绩为{1}",sum,sum/people);
上一篇下一篇

猜你喜欢

热点阅读