static void Main(string[] args)
{
while (true)
{
int[] al = new int[7]; //new出一个新的数组
for (int i = 0; i < al.Length; i++) //7个同学用for循环输入同学的分数
{
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++) //排序已排完 用for循环输出 取得都是索引
{
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();
}
}