用C#编写代码实现接收一个班级五名学员的姓名和三门课程的考试成绩_百 ...
发布网友
发布时间:2024-07-22 16:44
我来回答
共2个回答
热心网友
时间:2024-08-03 17:42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MidtermExercises
{
static class Student
{
public static void students()
{
Console.Write("学员姓名:");
string student = Console.ReadLine();
}
public static int getScore()
{
Console.Write("第一门课程考试成绩是:");
int frist = int.Parse(Console.ReadLine());
Console.Write("第二门课程考试成绩是:");
int second = int.Parse(Console.ReadLine());
Console.Write("第三门课程考试成绩是:");
int third = int.Parse(Console.ReadLine());
int sum = frist + second + third;
return sum;
}
public static void show()
{
int[] student = new int[5];
for (int i = 0; i < student.Length; i++)
{
students();
//getScore();
int sums = getScore();
Console.Write("三门课程考试总成绩是:" + sums);
int avg = sums / 3;
Console.Write("平均成绩是:" + avg);
student[i] = sums;
Console.WriteLine("\n");
}
int temp = 0;
foreach (int item in student)
{
if (item > temp)
{
temp = item;
}
}
int allavg , allsum = 0 ;
foreach (var item in student)
{
allsum += item;
}
allavg = allsum / student.Length;
Console.WriteLine("班级参考人数:{0},最高分:{1}, 总分平均成绩{2}", student.Length, temp,allavg);
}
}
}
在主方法中调用show
热心网友
时间:2024-08-03 17:41
用b/s的还是winform的?