您的位置:首页 > 其它

HDOJ 1157 Who's in the Middle(水)

2015-02-28 23:26 323 查看
【思路】:求中位数。这么水的题都写是不是显得我很low...其实我只是有强迫症而已。。

【AC代码】:

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

#define MAX 10000+10
int main(int argc, char** argv) {

//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n = 0;
while (cin >> n)
{
int i = 0;
int milk[MAX];
for (i = 0; i < n; i++)
cin >> milk[i];
sort(milk, milk+n);
cout << milk[n/2] << endl;;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: