5 2 4 1 3 5
3HintINPUT DETAILS: Five cows with milk outputs of 1..5 OUTPUT DETAILS: 1 and 2 are below 3; 4 and 5 are above 3.
#include <stdio.h> #define wbx 10005 int a[wbx]; #include <string.h> #include <algorithm> using namespace std; void solve() { int n,i; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); printf("%d\n",a[n/2]); } } int main() { solve(); return 0; }
原文地址:http://blog.csdn.net/sky_miange/article/details/41942479