[HDOJ 1157] Who's in the Middle (基础题)

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1157 
5482827 2012-03-06 18:16:49 Accepted 1157 0MS 384K 330 B C++ ajioy
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
    int main(){
    int n,tmp;
    vector<int> v;
    while(cin >> n){
    int len = n / 2;
    while(n--){
    	cin >> tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    cout << v[len] << endl; 
    v.clear();
    }
}

你可能感兴趣的:([HDOJ 1157] Who's in the Middle (基础题))