哪里错了

#include<iostream>
using namespace std;
//轴值为a[0],第一次划分
int one(int a[],int first,int end){
int i,j,temp;
i=first;
j=end;
while(i==j){ //相等的时候即找到           //这里改为i<j
while(i<j&&a[i]<a[j]) i++; //先从左边走
if(i<j){temp=a[i];a[i]=a[j];a[j]=temp;} //左边大则交换  这里加一句 j--
while(i<j&&a[i]<a[j]) j--; //再从右边走
if(i<j){temp=a[i];a[i]=a[j];a[j]=temp;} //右边小交换  这里加一句i++
}
return i; //跳出说明找到了
}
//快速排序递归
void quicksort(int a[],int first,int end){
int position;
if(first<end){
position=one(a,first,end);
quicksort(a,first,position-1);
quicksort(a,position+1,end);
}
}
int main(){
int i,a[5]={3,4,1,2,5};
quicksort(a,0,4);
for(i=0;i<5;i++){
cout<<a[i]<<' ';
}
cout<<endl;
return 0;
}

原文地址:https://www.cnblogs.com/apple-apple-apple/p/4363923.html