数组

冒泡排序

            Console.Write("请输入人数:");
            int renshu=int.Parse(Console.ReadLine());
            int[]chengji=new int[renshu];
            if (renshu >= 5)
            {
                for (int h = 1; h <= renshu; h++)
                {
                    Console.Write("请输入第" + h + "个人成绩");
                    chengji[h - 1] = int.Parse(Console.ReadLine());

                }
                for (int i = 0; i < renshu; i++)
                {
                    for (int j = i; j < renshu - 1; j++)
                    {
                        if (chengji[i] < chengji[j + 1])
                        {
                            int zhong = 0;
                            zhong = chengji[i];
                            chengji[i] = chengji[j + 1];
                            chengji[j + 1] = zhong;
                        }
                    }
                }
                int he = 0;
                for (int i = 0; i <= renshu - 1; i++)
                {
                    he = he + chengji[i];
                }
                double pj = (he - chengji[0] - chengji[1] - chengji[renshu - 2] - chengji[renshu - 1] / (renshu - 4));
                Console.Write("去掉两个最低分{},{}去掉两个最高分{},{},最后的成绩是:{4}", chengji[0], chengji[1], chengji[renshu - 2], chengji[renshu - 1], pj);

            }
            else 
            {
                Console.WriteLine("您输入的人数要大于等于5!!!");
            }
原文地址:https://www.cnblogs.com/liuyudong0825/p/4716776.html