Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么使用了unsigned int 还是WA?#include <stdio.h> #include <stdlib.h> int cmp(const void *a,const void *b) { if(*(unsigned int *)a>*(unsigned int *)b) return 1; else if(*(unsigned int *)a==*(unsigned int *)b) return 0; if(*(unsigned int *)a<*(unsigned int *)b) return -1; } int main() { unsigned int n; unsigned int sort[250005]; unsigned int i; scanf("%u",&n); for(i=0;i<n;i++) scanf("%u",&sort[i]); qsort(sort,n,sizeof(sort[0]),cmp); if(n%2) printf("%u\n",sort[(n+1)/2-1]); else{ if((sort[n/2-1]+sort[n/2])%2) printf("%u.5\n",(sort[n/2-1]+sort[n/2])/2); else printf("%u\n",(sort[n/2-1]+sort[n/2])/2); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator