码迷,mamicode.com
首页 > 其他好文 > 详细

倒数第二小的数

时间:2014-12-25 07:47:07      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

题目: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.14159265359



int 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;
}

 

倒数第二小的数

标签:

原文地址:http://www.cnblogs.com/miaoz/p/4183811.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!