bzoj1753[Usaco2005 qua]Who's in the Middle*

bzoj1753[Usaco2005 qua]Who's in the Middle

题意:

输入N个数,输出升序排列后中间那个数。n≤10000。

题解:

本来想交个python的结果莫名奇妙RE了~

代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <queue>
 5 #define inc(i,j,k) for(int i=j;i<=k;i++)
 6 #define maxn 10010
 7 using namespace std;
 8 
 9 inline int read(){
10     char ch=getchar(); int f=1,x=0;
11     while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
12     while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
13     return f*x;
14 }
15 int a[maxn],n;
16 int main(){
17     n=read(); inc(i,1,n)a[i]=read(); sort(a+1,a+n+1); printf("%d",a[(n+1)/2]); return 0;
18 }

20160926

原文地址:https://www.cnblogs.com/YuanZiming/p/5910779.html