首页 > 学院 > 开发设计 > 正文

POJ2388 Who's in the Middle

2019-11-08 03:27:57
字体:
来源:转载
供稿:网友

问题链接:POJ2388 Who's in the Middle。

问题简述:输入n个数,找出一个数,满足至少有一半大于或等于它,并且有一半小于或等于它。

问题分析:一个求中间数的问题。

程序说明:(略)。

AC的C++语言程序如下:

/* POJ2388 Who's in the Middle */#include <iostream>#include <algorithm>using namespace std;const int N = 10000;int a[N];int main(){    int n;    // 输入数据    cin >> n;    for(int i=0; i<n; i++)        cin >> a[i];    // 排序    sort(a, a+n);    // 输出结果    cout << a[n / 2] << endl;    return 0;}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表