void shellsort(int A[], int len)
{
int j;
int increment = len;
do{
increment = increment/3+1;
printf("increment = %d\n", increment);
for(int i = increment; i < len; i++){
if(A[i] < A[i-increment]){
int tmp = A[i];
for(j = i-increment; j >= 0 && A[j] >= tmp; j -= increment)
A[j+increment] = A[j];
A[j+increment] = tmp;
}
}
}while(increment >1);
}
网友评论