主题:哪里错了?
//这个程序哪里错了?
#include <stdio.h>
#include <math.h>
int partions(int a[],int low,int high)
{
int pivotkey=a[low];
a[0]=a[low];
while(low<high)
{
while(low<high && a[high]>=pivotkey)--high;
a[low]=a[high];
while(low<high && a[low]<=pivotkey)
++low;
a[high]=a[low];
}
a[low]=a[0];
return low;
}
void qsort(int a[],int low,int high)
{
int pivottag;
if(low<high)
{ //递归调用
pivottag=partions(a,low,high);
qsort(a,low,pivottag-1);
qsort(a,pivotta+1,high);
}
}
void quicksort(int a[],int n)
{
qsort(a,1,n);
}
int main()
{
int i,a[11]={0,11,12,5,6,13,8,9,14,7,10};
for(i=0;i<11;++i);printf("%3d",a[i]);
printf("\n");
quicksort(a,10);
for(i=0;i<11;++i);printf("%3d ",a[i]);
return 0;
}
#include <stdio.h>
#include <math.h>
int partions(int a[],int low,int high)
{
int pivotkey=a[low];
a[0]=a[low];
while(low<high)
{
while(low<high && a[high]>=pivotkey)--high;
a[low]=a[high];
while(low<high && a[low]<=pivotkey)
++low;
a[high]=a[low];
}
a[low]=a[0];
return low;
}
void qsort(int a[],int low,int high)
{
int pivottag;
if(low<high)
{ //递归调用
pivottag=partions(a,low,high);
qsort(a,low,pivottag-1);
qsort(a,pivotta+1,high);
}
}
void quicksort(int a[],int n)
{
qsort(a,1,n);
}
int main()
{
int i,a[11]={0,11,12,5,6,13,8,9,14,7,10};
for(i=0;i<11;++i);printf("%3d",a[i]);
printf("\n");
quicksort(a,10);
for(i=0;i<11;++i);printf("%3d ",a[i]);
return 0;
}