如题,当读到第四百多个数的时候就无法继续读入了。但是提交到oj上出来的是WA,意思应该是可以运行但结果不对吧。
#include<stdio.h>
int num[100000];
int sort(int low, int high);
void quick(int start,int end);
int main()
{
int tot;
int i;
scanf("%d",&tot);
for(i=0;i<tot;i++){
scanf("%d",&num[i]);
}
quick(0,tot-1);
printf("%d",num[0]);
for(i=1;i<tot;i++){
printf(" %d",num[i]);
}
printf("\n");
return 0;
}
int sort(int low, int high){
int temp=num[low];
while(low<high){
while(low<high&&num[high]>=temp) high--;
if(low>=high) break;
else num[low]=num[high];
while(low<high&&num[low]<=temp) low++;
if(low>=high) break;
else num[high]=num[low];
num[low]=temp;
}
return low;
}
void quick(int start,int end){
int sor=sort(start,end);
if(sor>start+1) quick(start,sor-1);
if(sor<end-1) quick(sor+1,end);
}
如图