敬请诸位帮我看看下面的程序哪错了,这是个shell_sort question.
#include<stdio.h>
#include<conio.h>
void shell_sort(int a[],int n);
int main(void)
{
int a[10],i;
printf("Enter ten numbers:\n");
for(i=0;i<=9;i++)
scanf("%d",&a[i]);
shell_sort(a,10);
for(i=0;i<=9;i++)
printf("%3d",a[i]); printf("\n");
getch();
return 0;
}
void shell_sort(int a[],int n) /*n=10*/
{
int i,j,flag,increment,exchange;
/*increment=n-1;*/
do
{
#if 0
increment=increment/2;
#endif
increment=(n-1)/2; /*主要就是这个地方*/
do
{
flag=1;
for(i=0;i<=n-1-increment;i++)
{
j=i+increment;
if(j>n-1)
break;
if(a[i]>a[j])
{
flag=0;
exchange=a[i];
a[i]=a[j];
a[j]=exchange;
}
}
}while(flag==0);
}while(increment>1);
}
shell_sort question!