首页 > 编程语言 > 详细

hdu 1029 Ignatius and the Princess IV(排序)

时间:2015-08-14 13:03:24      阅读:206      评论:0      收藏:0      [点我收藏+]

题意:求出现次数>=(N+1)/2的数

思路:排序后,输出第(N+1)/2个数

技术分享
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[999999];

int main(){
    int n,i;
    while(~scanf("%d",&n)){
        for(i=0;i<n;++i)
            scanf("%d",&a[i]);
        sort(a,a+n);
        printf("%d\n",a[(n+1)/2-1]);
    }
    return 0;
}
View Code

 

hdu 1029 Ignatius and the Princess IV(排序)

原文:http://www.cnblogs.com/bofengyu/p/4729540.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!