现在的位置: 首页 > 综合 > 正文

hdoj1029

2019年07月31日 ⁄ 综合 ⁄ 共 288字 ⁄ 字号 评论关闭

链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1029
//水题
//由于为奇数个,故排序后中间那个一定是所求
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
 int n;
 int *k;
 int i;
 while (cin >> n) {
  k = (int *)malloc(sizeof(int)*n);
  for (i = 0; i < n; i++) {
   cin >> k[i];
  }
  sort(k, k+n);
  cout << k[n/2] << endl;
 }
 return 0;
}

【上篇】
【下篇】

抱歉!评论已关闭.