static void Main(string[] args)
{
while (true)
{
int[] al = new int[7];
for (int i = 0; i < al.Length; i++)
{
Console.Write("请输入" + (i + 1) + "位同学的分数");
al[i] = Convert.ToInt32(Console.ReadLine());
}
for (int j = 0; j < al.Length; j++)
{
Console.WriteLine("请输入" + (j + 1) + "位同学的分数" + al[j] + "分");
}
for (int i = 1; i <= al.Length - 1; i++)
{
for (int j = 1; j <= al.Length - i; j++)
{
if (al[j] > al[j - 1])
{
int t = al[j];
al[j] = al[j - 1];
al[j - 1] = t;
}
}
}
for (int k = 0; k < al.Length; k++)
{
Console.WriteLine(al[k]);
}
int x = 0;
for (int s = 0; s < al.Length; s++)
{
x = x + al[s];
}
Console.WriteLine("总分为" + x);
double n = (1.0 * x - al[0] - al[1] - al[al.Length - 1] - al[al.Length - 2]) / (al.Length - 4);
Console.WriteLine("平均分为:" + n);
Console.ReadLine();
}
}
时间: 2024-12-28 00:31:27