AC的意志!

Nth Largest ValueTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1140Accepted Submission(s): 892

Problem Description

For this problem, you will write a program that prints theNthlargest value in a fixed sized array of integers. To make things simple,Nwill be 3 and the array will always be have 10 decimal integer values.

Input

The first line of input contains a single integerP, (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 3rdlargest 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

Source

AC代码:

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int a[15];int main() {int P, tmp;scanf("%d", &P);while(P–) {scanf("%d", &tmp);for(int i=0; i<10; i++ ){scanf("%d", &a[i]);}sort(a, a+10);printf("%d %d\n", tmp, a[7]);}return 0;}

,就是对虚怀若谷谦虚谨慎八个字真正理解的人,

AC的意志!

相关文章:

你感兴趣的文章:

标签云: