I read the following codes in "The C programming language edition 2"
/* shellsort: sort v[0] ... v[n-1] into increasing order */
void shellsort(int v[], int n) {
int gap, i, j, temp;
for (gap = n/2; gap > 0; gap /= 2)
for (i = gap; i < n; i++)
for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap) {
temp = v[j];
v[j] = v[j+gap];
v[j+gap] = temp;
}
}
What confuse me is that there's no ";" at the end of "for loop line", I assume it should be
for (gap = n/2; gap > 0; gap /= 2) ;
for (i = gap; i < n; i++);
for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap) {
temp = v[j];
v[j] = v[j+gap];
v[j+gap] = temp;
}
How could I wrap it around intuitively?