您的位置:首页 > 其它

Who's in the Middle

2015-07-31 14:16 344 查看
题目链接:http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=3&problemid=21

方法:排序

思路:排序后选出中间值,简单题

难点:注意数组下标的对应关系

#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int h[10000+10];
    int n;
    while(~scanf("%d",&n))
    {
        for(int i = 1; i <= n;i++)
            scanf("%d",&h[i]);
        sort(h+1,h+n+1);
        printf("%d\n",h[n/2+1]);
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: