码迷,mamicode.com
首页 > 其他好文 > 详细

评委打分去掉最高最低求平均

时间:2015-06-19 10:07:45      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

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();
        }
    }
}

 

评委打分去掉最高最低求平均

标签:

原文地址:http://www.cnblogs.com/qixinjian/p/4587618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!