給你10個數,請輸出第3大的數即可,簡單吧
數據保證每個數都不同
- 輸入
- 第一行有一個整數n,代表有n組測試數據
然後有n行,每行10個整數,所有的數大於0小於1000 - 輸出
- 每行輸出第三大的數
- 樣例輸入
-
2 383 886 777 915 793 335 386 492 649 421 8 722 783 350 657 97 827 126 269 71
- 樣例輸出
-
793 722
#include<iostream> #include<string.h> #include<stdio.h> #include<ctype.h> #include<algorithm> #include<stack> #include<queue> #include<set> #include<math.h> #include<vector> #include<deque> #include<list> using namespace std; bool cmp(int a,int b) { return a>b; } int main() { int n,i,a[10]; while(scanf("%d",&n)!=EOF) { while(n--) { for(i=0;i<10;i++) cin>>a[i]; sort(a,a+10,cmp); printf("%d\n",a[2]); } } return 0; }