HDU 1157 Who's in the Middle
2012-09-06 18:50
393 查看
#include<stdio.h>
#include<stdlib.h>
int a[10005];
int cmp(const void *a,const void *b)
{
return *(int *)a - *(int *)b;
}
int main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++) scanf("%d",&a[i]);
qsort(a,n,sizeof(a[0]),cmp);
printf("%d\n",a[(n-1)/2]);
}
return 0;
}
#include<stdlib.h>
int a[10005];
int cmp(const void *a,const void *b)
{
return *(int *)a - *(int *)b;
}
int main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++) scanf("%d",&a[i]);
qsort(a,n,sizeof(a[0]),cmp);
printf("%d\n",a[(n-1)/2]);
}
return 0;
}
相关文章推荐
- 杭电 HDU 1157 Who's in the Middle
- HDU 1157 POJ 2388 Who's in the Middle 求中位数
- hdu 1157 Who's in the Middle
- HDU 1157 Who's in the Middle【水题】
- HDU 1157 Who's in the Middle
- HDU 1157 Who's in the Middle(排序取中间值)
- HDU 1157 Who's in the Middle (快速排序 or 任意排序)
- hdu 1157 (1.3.7) Who's in the Middle
- HDU—— 1157 Who's in the Middle
- hdu 1157 Who's in the Middle
- HDU 1157 Who's in the Middle
- POJ 2388 && HDU 1157 Who's in the Middle(水~)
- HDU 1157 Who's in the Middle
- HDU 1157 Who's in the Middle
- HDU 1157 Who's in the Middle
- 杭电1157(Who's in the Middle)
- hdu Who's in the Middle
- HDU 1.3.8 Who's in the Middle (排序|取中位数)
- [HDOJ 1157] Who's in the Middle (基础题)
- HDU 1.3.8 Who's in the Middle