(HDU)1157 -- Who's in the Middle(哪个居中)
题目链接:http://vjudge.net/problem/HDU-1157
找中位数。
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 5 using namespace std; 6 7 int main() 8 { 9 int n,i,a[10010]; 10 while(~scanf("%d",&n)) 11 { 12 for(i=1;i<=n;i++) 13 scanf("%d",&a[i]); 14 sort(a+1,a+1+n); 15 printf("%d\n",a[(n+1)/2]); 16 } 17 return 0; 18 }