poj 2388 Who's in the Middle
一个快排,水题。
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int n, a[11000]; 5 6 int cmp(const void *_p, const void *_q) 7 { 8 int *p = (int *)_p; 9 int *q = (int *)_q; 10 return *p - *q; 11 } 12 13 int main() 14 { 15 while(~scanf("%d",&n)) 16 { 17 for(int i = 0; i < n; i ++) 18 { 19 scanf("%d",&a[i]); 20 } 21 qsort(a,n,sizeof(a[0]),cmp); 22 printf("%d\n",a[(n+1)/2-1]); 23 } 24 25 return 0; 26 }