Problem Description

The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.

One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one contestant to another, because judges with any relationship whatsoever with a specific contestant are temporarily excluded for scoring his/her performance.

Basically, scores given to a contestant’s performance by the judges are averaged to decide his/her score. To avoid letting judges with eccentric viewpoints too much influence the score, the highest and the lowest scores are set aside in this calculation. If the same highest score is marked by two or more judges, only one of them is ignored. The same is with the lowest score. The average, which may contain fractions, are truncated down to obtain final score as an integer.

You are asked to write a program that computes the scores of performances, given the scores of all the judges, to speed up the event to be suited for a TV program.

Input

The input consists of a number of datasets, each corresponding to a contestant’s performance. There are no more than 20 datasets in the input.

A dataset begins with a line with an integer n, the number of judges participated in scoring the performance (3 ≤ n ≤ 100). Each of the n lines following it has an integral score s (0 ≤ s ≤ 1000) marked by a judge. No other characters except for digits to express these numbers are in the input. Judges’ names are kept secret.

The end of the input is indicated by a line with a single zero in it.

Output

For each dataset, a line containing a single decimal integer indicating the score for the corresponding performance should be output. No other characters should be on the output line.

Sample Input

3

1000

342

0

5

2

2

9

11

932

5

300

1000

0

200

400

8

353

242

402

274

283

132

402

523

0

Sample Output

342

7

300

326

分数都是整数!平均分也要是整数!

评委打分,去掉一个最高分,去掉一个最低分,求剩下的平均分!

不用四舍五入。直接舍去小数位就可以。

  1. import java.util.Scanner;
  2. public class Main{
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. while(sc.hasNext()){
  6. int n=sc.nextInt();
  7. if(n<=0){
  8. return ;
  9. }
  10. int sum =0;
  11. int min = sc.nextInt();
  12. int max=min;
  13. sum=max;
  14. int b;
  15. for(int i=1;i<n;i++){
  16. b = sc.nextInt();
  17. if(b>max){
  18. max=b;
  19. }
  20. if(b<min){
  21. min=b;
  22. }
  23. sum+=b;
  24. }
  25. sum=sum-min-max;
  26. System.out.println((int)(sum/(n-2)));
  27. }
  28. }
  29. }

HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)的更多相关文章

  1. hdu2309ICPC Score Totalizer Software

    Problem Description The International Clown and Pierrot Competition (ICPC), is one of the most disti ...

  2. HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)

    HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...

  3. HDOJ(HDU).2660 Accepted Necklace (DFS)

    HDOJ(HDU).2660 Accepted Necklace (DFS) 点我挑战题目 题意分析 给出一些石头,这些石头都有自身的价值和重量.现在要求从这些石头中选K个石头,求出重量不超过W的这些 ...

  4. HDOJ(HDU).1003 Max Sum (DP)

    HDOJ(HDU).1003 Max Sum (DP) 点我挑战题目 算法学习-–动态规划初探 题意分析 给出一段数字序列,求出最大连续子段和.典型的动态规划问题. 用数组a表示存储的数字序列,sum ...

  5. HDOJ(HDU).1045 Fire Net (DFS)

    HDOJ(HDU).1045 Fire Net [从零开始DFS(7)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HD ...

  6. HDOJ(HDU).1241 Oil Deposits(DFS)

    HDOJ(HDU).1241 Oil Deposits(DFS) [从零开始DFS(5)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架 ...

  7. HDOJ(HDU).1035 Robot Motion (DFS)

    HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...

  8. HDOJ(HDU).1412 {A} + {B} (STL SET)

    HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...

  9. HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)

    HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...

随机推荐

  1. Java_Activiti5_菜鸟也来学Activiti5工作流_之初识BPMN2.0的简单结构(五)

    <?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http:// ...

  2. instanceof的用法②

    其实这个问题以前也困扰过我.我个人理解的一个应用场合就是,当你拿到一个对象的引用时(例如参数), 你可能需要判断这个引用真正指向的类.所以你需要从该类继承树的最底层开始,使用instanceof操作符 ...

  3. C#使用Process类调用外部程序(转)

    在程序开发中,一个程序经常需要去调用其他的程序,C#中Process类正好提供了这样的功能.它提供对本地和远程进程的访问并使您能够启动和停止本地系统进程.一.启动进程实例 Process myProc ...

  4. android如何获取手机型号和版本号

    public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView ...

  5. 关于C#与.NET Framework

    前几天,有一个做测试的问我.NET Framework是什么,和C#是什么关系呢. 下面我就来解释一下.NET Framework是什么:.NET Framework是一个框架,是应用程序运行时所需要 ...

  6. [转]Delphi I/O Errors

    The following are the Windows API (and former DOS) IO errors, which are also the IO errors often ret ...

  7. javascript的选项卡

    主要用的索引值 首先 写三个按钮 <input type="button" > <input type="button" > <i ...

  8. Spring 整合Redis 出现 afterPropertiesSet signature: ()V) Incompatible argument to function 解决办法

    正在做SpringMVC+Redis整合的练习 使用的是 spring-data-redis 和 Jedis 配置好之后出现了以下错误: Caused by: java.lang.VerifyErro ...

  9. Html5新增加的属性

    用2中方法给单复选框增加新的特性,使直接点击文字就可以被选中 1.将选项放入label标签内添加for属性,并在input标签内添加id,两者值相同. 2.将input标签放到label标签内,注意l ...

  10. shell脚本中的标准输出重定向使用涵义

    0表示标准输入 1表示标准输出 2表示标准错误输出 > 默认为标准输出重定向,与 1> 相同 2>&1 意思是把 标准错误输出 重定向到 标准输出. &>fil ...