HUD 3279 Nth Largest Value
来源:互联网 发布:电脑摇奖软件 编辑:程序博客网 时间:2024/06/07 22:52
Nth Largest Value
Problem Description
For this problem, you will write a program that prints theNth 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
41 1 2 3 4 5 6 7 8 9 10002 338 304 619 95 343 496 489 116 98 1273 931 240 986 894 826 640 965 833 136 1384 940 955 364 188 133 254 501 122 768 408
Sample Output
1 82 4893 9314 768
题意:给出一行,找第三大的数字。
#include<stdio.h>#include<string.h>int main(){ int t,i,j,n=0; int r[4]; scanf("%d",&t); while(t--) { memset(r,0,sizeof(r)); scanf("%d",&n); for(i=0;i<10;i++) { scanf("%d",&j); if(j>=r[1]) r[3]=r[2],r[2]=r[1],r[1]=j; else if(j>=r[2]) r[3]=r[2],r[2]=j; else if(j>=r[3]) r[3]=j; } printf("%d %d\n",n,r[3]); } return 0;}
0 0
- HUD 3279 Nth Largest Value
- hd 3279 Nth Largest Value
- HDU- 3279 - Nth Largest Value
- HDU 3279 Nth Largest Value
- JAVA hdu 3279 Nth Largest Value
- hdoj 3279 Nth Largest Value 水过~
- poj3781 Nth Largest Value
- Nth Largest Value
- Nth Largest Value
- POJ 3781 Nth Largest Value G++
- 【STL】poj 3781 Nth Largest Value
- http://poj.org/problem?id=3781&&Nth Largest Value
- C语言代码-水题poj3781--Nth Largest Value
- Find Nth maximum value in SQL Server
- (超水)Nth Largst Value(p3781)
- HUD
- Find Largest Value in Each Tree Row
- Find Largest Value in Each Tree Row
- expression "eps"
- 第八周训练2鸡兔共笼
- python学习笔记(2)网络编程
- Hadoop集群搭建示意图即相应配置文件汇总
- friend function in C++
- HUD 3279 Nth Largest Value
- The Design of Callback between Java and Native
- Django runserver 支持https
- url %E4%BD%A0%E5%A5%BD 编码问题
- Ubuntu GTK theme
- TCP/IP协议栈之五---------总结
- Session理解
- springMVC Ajax实现和原理
- 搜索算法-搜索的优化