Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么使用了unsigned int 还是WA?

Posted by sunflowwer at 2006-08-12 10:42:22 on Problem 2623
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator