#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
int *a = new int[n+1];
for(int i = 0; i < n; i++)
cin >> a[i];
sort(a, a+n);
cout << a[n/2] << endl;
delete [] a;
}
return 0;
}HDU 1157 中位数有更高效的方法,编程之美又提到,以后实践
最新推荐文章于 2023-01-30 11:48:12 发布
本文介绍了一段使用C++实现的代码,通过输入数组并进行排序,输出数组中间的元素作为中位数。

632

被折叠的 条评论
为什么被折叠?



