zoukankan      html  css  js  c++  java
  • 评委打分去掉最高最低求平均

    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();
            }
        }
    }
  • 相关阅读:
    巴科斯范式和sql语言
    mysql 视图
    1503
    mysql SQL_CALC_FOUND_ROWS
    create table xxx as select 与 create table xxx like
    mysql 1030 Got error 28 from storage engine
    python -- 装饰器入门
    12C新特性 -- 共享asm口令文件
    MySQL子查询的优化
    MySQL的explain
  • 原文地址:https://www.cnblogs.com/qixinjian/p/4587618.html
Copyright © 2011-2022 走看看