首页 > 代码库 > 倒数第二小的数

倒数第二小的数

题目:HDOJ 2561

#include <iostream>#include <cstdio>#include <cmath>#include <iomanip>#include <algorithm>#include <vector>#include <map>#include <string>#include <sstream>#include <cstring>using namespace std;//const double E = 2.71828182845904523536;//const double PI= 3.14159265359int main(){    int C;    cin >> C;    while(C--){            int n;        cin >> n;        int h[2]= {101,101};        int max= 0;        int t;        while(n--){            cin >> t;                        if(t< h[0] || t< h[1]){                h[max]= t;                max= (h[0]>h[1])?0:1;            }        }        t= (h[0]>h[1])?h[0]:h[1];        cout << t << endl;            }    return 0;}

 

倒数第二小的数