using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 数组 { class Class1 { static void main (string[] args) { Console.WriteLine("请输入人数:"); int renshu = int.Parse(Console.ReadLine()); int[] chengji=new int[renshu]; if (renshu >= 5) { for (int p = 1; p <= renshu; p++) { Console.Write("请输入第" + p + "人的成绩:"); chengji[p - 1] = int.Parse(Console.ReadLine()); } int zhong = 0; for (int i = 0; i < renshu; i++) { for (int j = i; j < renshu - 1; j++) { if (chengji[j + 1] > chengji[i]) { zhong = chengji[j+1]; chengji[j+1] = chengji[i]; chengji[i] = zhong; } } } int he = 0; for (int k = 0; k < renshu; k++) { he = he + chengji[k]; } double pj = (1.0 * he - chengji[1] - chengji[2] - chengji[renshu - 1] - chengji[renshu - 2]) / renshu - 4; Console.WriteLine("去掉两个最高分{0}{1},去掉两个最低分{2}{3},最终得分为{4}", chengji[1], chengji[2], chengji[renshu - 1], chengji[renshu - 2], pj); } else { Console.WriteLine("请输入人数大于等于5"); } Console.ReadLine(); } } }
时间: 2024-10-05 04:29:26