题解 | #Median#
Median
https://www.nowcoder.com/practice/b5da3f56557f42978ca87afedbd85fbe
#include <bits/stdc++.h>
using namespace std;
//0 1 2 3
int main() {
int n;
vector<int>v;
while(cin>>n){
while(n--){
int temp;cin>>temp;
v.push_back(temp);
}
}
sort(v.begin(),v.end());
cout<<v[(v.size()%2==1?v.size()/2:v.size()/2-1)]<<endl;
}
// 64 位输出请用 printf("%lld")
题目翻译:
查看13道真题和解析