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

为什么WA呀,请大家帮忙看看!

Posted by Ilikethis at 2009-02-28 15:44:53 on Problem 2371
#include<stdio.h>
int QKpass(int r[],int low,int high)
{  int x=r[low];
   while(low<high)
   {  while(low<high&&r[high]>=x)
          high--;
      if(low<high) {r[low]=r[high];low++;}
	  while(low<high&&r[low]<=x)
		  low++;
	  if(low<high) {r[high]=r[low];high--;}
   }
   r[low]=x;
   return low;
}
void QKsort(int r[],int low,int high)
{  int pos;
   if(low<high)
   {  pos=QKpass(r,low,high);
      QKsort(r,low,pos-1);
	  QKsort(r,pos+1,high);
   }
}
int main()
{  int r[100005],i,n;
   scanf("%d",&r[0]);
   for(i=1;i<=r[0];i++)
	   scanf("%d",&r[i]);
   QKsort(r,1,r[0]);  //快速排序
   printf("###\n");
   scanf("%d",&r[0]);
   for(i=1;i<=r[0];i++)
   {  scanf("%d",&n);
      printf("%d\n",r[n]);
   }
   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