-->
当前位置:首页 > 题库 > 正文内容

程序填空题:The implementation of Shellsort Algorithm with increment sequence {1,3,7,11}

Luz4年前 (2021-05-10)题库806
Following function Shellsort(int A[], int N) is the implementation of Shellsort Algorithm with increment sequence {1,3,7,11}. Please fill in the blanks.

```c++
void Shellsort( int A[ ], int N )
{ int i, j, k, Increment, Inc[]={1,3,7,11};
int Tmp;

for ( k=3; k>=0; k--) {
@@[Increment = Inc[k]](3);
for ( i = Increment; i < N; i++ ) {
Tmp = A[ i ];
for ( j = i; j >= Increment; j -= Increment )
if( Tmp < A[ j - Increment ] )
@@[A[ j ] = A[ j - Increment ]](3);
else break;
A[ j ] = Tmp;
}
}
}
```






答案:
第1空:Increment = Inc[k]

第2空:A[ j ] = A[ j - Increment ]

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。