POJ_2388_Who's in the Middle(快排)
# include<stdio.h> # include <string.h> # include <algorithm> using namespace std; bool comp(int a,int b) { return a>b; } int main() { int n,i; int a[10005]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n,comp); if(n%2 == 0 ) printf("%d\n",(a[n/2-1]+a[n/2])/2); else printf("%d\n",a[n/2]); return 0; }