第一题 我的答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication23
{
class Program
{
static void Main(string[] args)
{
int i=1;
int k = 0;
int sum = 0;
Console.WriteLine("请输入班级人数!");
int renshu = Convert.ToInt32(Console .ReadLine ());
Console.WriteLine("请输入每个学生人数!");
while(i<=renshu)
{
Console.WriteLine("请输入第{0}位同学的成绩",i);
k = Convert.ToInt32(Console.ReadLine ());
sum += k;
i++;
}
Console.WriteLine("一共是{0}人,总成绩是{1},平均成绩是{2}",renshu,sum,sum*1.0/renshu);
Console.ReadKey();
}
}
}
时间: 2024-12-14 20:15:11