POJ 2388 Who's in the Middle
题目链接:POJ 2388【Who's in the Middle】
思路
求中位数,排序输出中间的数字。
代码
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
const int N = 1e5 + 10;
int a[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin>> a[i];
}
sort(a + 1, a + 1 + n);
cout << a[(n + 1) >> 1] << endl;
return 0;
}