Problem Description
For this problem, you will write a program that prints the Nth largest value in a fixed sized array of integers. To make things simple, N will be 3 and the array will always be have 10 decimal integer values.
 
Input
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing the data set number, followed by a space,followed by 10 space separated decimal integers whose values are between 1 and 1000 inclusive.
 
Output
For each data set, generate one line of output with the following values: The data set number as a decimal integer, a space, and the 3rd largest value of the corresponding 10 integers.
 
Sample Input
4
1 1 2 3 4 5 6 7 8 9 1000
2 338 304 619 95 343 496 489 116 98 127
3 931 240 986 894 826 640 965 833 136 138
4 940 955 364 188 133 254 501 122 768 408
 
Sample Output
1 8
2 489
3 931
4 768
 
 #include <stdio.h> 

 int main(){
int T;
int n;
int number;
int i;
int max;
int middle;
int min; scanf("%d",&T); while(T--){
max=; //对最大的三个数进行初始化
middle=;
min=;
scanf("%d",&n); for(i=;i<;i++){
scanf("%d",&number); if(number>max){ //如果找到当前最大的数,舍去最小数
min=middle;
middle=max;
max=number;
} else if(number>middle){ //如果找到当前第二大的数,舍去最小数
min=middle;
middle=number;
} else if(number>min) //如果找到当前第三大的数,舍去最小数
min=number;
} printf("%d %d\n",n,min); }
return ;
}

最新文章

  1. jqueryAjax在客户端发送请求的方式
  2. C#.NET 大型企业信息化系统集成快速开发平台 4.2 版本 - 基于数据库资源的多语言实现
  3. Mac +WebStorm+nodeJs+Freemarker.js的安装与使用
  4. AccessHelper 需修改
  5. Scau 8633 回文划分 mancher + dp
  6. 关于oracle-12514错误的修改方法
  7. MySQL 索引、视图、DML
  8. 每天一个JS 小demo之个人信息添加。主要知识点:DOM操作中的表格操作,节点操作
  9. Matplotlib初体验
  10. 一次saltstack环境变量的坑
  11. C++-int类型整数超出范围后的处理
  12. burp抓取手机模拟器流量
  13. 分布式文件系统(HDFS)与 linux系统文件系统 对比
  14. python的MD5
  15. js_计时器之setInterval
  16. 存储过程DT参数
  17. JAVA多线程Thread VS Runnable详解
  18. j.u.c系列(07)---之读写锁:ReentrantReadWriteLock
  19. 转-spring boot web相关配置
  20. Mysql replace into

热门文章

  1. (DP)51NOD 1049 最大子段和
  2. 洛谷 P1462 通往奥格瑞玛的道路(spfa+二分搜索)(4boy)
  3. [Qt Creator 快速入门] 第8章 界面外观
  4. Android 性能优化(22)*性能工具之「Hierarchy Viewer」 Hierarchy Viewer Walkthrough
  5. LN : leetcode 241 Different Ways to Add Parentheses
  6. css的新特性 calc () 使用
  7. setTimeout 0
  8. 3星|林毅夫《战胜命运》:事实证明华盛顿共识是错误的,GIFF是穷国发展正道。
  9. c3p0参数详解
  10. HDU_1874_畅通工程续_最短路问题