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

改了一下,过了。见内

Posted by zhucheng at 2005-10-02 22:26:56 on Problem 2623
In Reply To:改了 也没用 郁闷 Posted by:wahahaha at 2005-10-02 22:23:00
#include <stdio.h>
#include <math.h>
#define N 250000
long a[N];
long p(long l,long r)
{
   long i=l-1,j=r+1,tmp=a[l],tmp2;
   while(i<j) 
   {
      while(a[++i]<tmp);
      while(a[--j]>tmp);
      if(i<j)
      {
          tmp2=a[i];
          a[i]=a[j];
          a[j]=tmp2;       
      }          

   } 
    return j;



}
void qsort(long l,long r)
{
   long mid; 
   if(l<r)
   {
     mid=p(l,r);
     qsort(l,mid);
     qsort(mid+1,r);      
   }  
}




int main()
{
   long n,i;
   double result; 
   scanf("%ld",&n);
   for(i=1;i<=n;i++)
       scanf("%ld",&a[i]);
   qsort(1,n);
   if(n%2==1)
     printf("%ld.0\n",a[(n+1)/2]);
   else 
   {
       result=1.0*a[n/2]+1.0*a[(n+2)/2];
       result/=2.0;
       printf("%.1lf\n",result)   ;
   }    
   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