快速排序代码,执行后没结果,那个环节出了问题求大佬们指教 感谢
#include<stdio.h>void swap(int *d,int k,int m)
{
int temp;
temp=*(d+k);
*(d+m)=*(d+k);
*(d+m)=temp;
}
int sort(int *b,int lows,int highs)
{
//int low,high;
int middle=b[0];
if(lows<highs)
{
while(lows<highs&&b[highs]>=middle)
highs--;
swap(b,highs,lows);
while(lows<highs&&b[lows]<=middle)
lows++;
swap(b,lows,highs);
}
return lows;
}
void Quicksort(int a[],int low,int high)
{
int mid;
mid=sort(a,low,high);
Quicksort(a,1,mid-1);
Quicksort (a,mid+1,9);
}
int main()
{
int i;
int a[10]={50,10,90,30,70,40,80,60,20,100};
Quicksort(a,1,9);
for(i=0;i<10;i++)
printf("%2d",a[i]);
printf("victory");
return 0;
}