| ||||||||||
| 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 | |||||||||
为什么WA呀,请大家帮忙看看!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator