hdoj1029

来源:互联网 发布:齐鲁大学生软件大赛 编辑:程序博客网 时间:2024/05/20 02:26

链接:
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;
}

原创粉丝点击