本文主要是介绍POJ - 2388 Who's in the Middle,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.题面
http://poj.org/problem?id=3481
2.解题思路
排序后求中位数,表示解题代码还没我的头文件长
3.解题代码
/*****************************************************************> File Name: tmp.cpp> Author: Uncle_Sugar> Mail: uncle_sugar@qq.com> Created Time: 2016年02月18日 星期四 12时44分45秒****************************************************************/
# include <cstdio>
# include <cstring>
# include <cmath>
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <set>
# include <map>
# include <vector>
# include <stack>
# include <algorithm>
using namespace std;const int debug = 1;
const int size = 10000 + 10;
typedef long long ll;int cow[size];
int main()
{int i,j,k;int n;while (cin >> n){for (i=0;i<n;i++)cin >> cow[i];sort(cow,cow+n);cout << cow[(n-1)/2] << '\n';}return 0;
}
这篇关于POJ - 2388 Who's in the Middle的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!