2018-11-08
2018-11-08 本文已影响0人
一只皮皮橙
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//输入班级人数,然后依次输入学员成绩,计算班级学员的平均成绩和总成绩
Console.WriteLine("请输入班级人数");
string str_number=Console.ReadLine();
int number=Convert.ToInt32(str_number);
int i = 0;
int sum = 0;
while (i < number)
{
Console.WriteLine("请输入第{0}个学生的成绩",i+1);
string str_grade = Console.ReadLine();
int grade = Convert.ToInt32(str_grade);
i++;
sum += grade;
}
Console.WriteLine("班级学生成绩的总和{0},平均成绩{1}",sum,(sum/number));
Console.ReadKey();
}
}
}