杭电acm1157
http://acm.hdu.edu.cn/showproblem.php?pid=1157
简单求中位数
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h> 2 #include<stdlib.h> 3 int ans[100000]; 4 int cmp(const void *a,const void *b) 5 { 6 return *(int *)a-*(int *)b; 7 } 8 int main() 9 { 10 int n,i; 11 while(scanf("%d",&n)!=EOF) 12 { 13 for(i=0;i<n;i++) 14 scanf("%d",&ans[i]); 15 qsort(ans,n,sizeof(ans[0]),cmp); 16 printf("%d\n",ans[n/2]); 17 } 18 return 0; 19 }