3 Invented in 1959 by D. L. Shell
5 Sorts an array of integers
13 void shellsort(int v
[], int n
)
17 for(gap
= n
/2; gap
> 0; gap
/=2)
19 for(i
= gap
; i
< n
; i
++)
21 for(j
= i
- gap
; j
>=0 && v
[j
]>v
[j
+gap
]; j
-=gap
)
33 int data
[10] = { 9, 12, 54, 90, 0, 100, 65, 32, 54, 81};
36 for(i
= 0; i
< 10; ++i
) { printf("%d\n", data
[i
]); }
40 for(i
= 0; i
< 10; ++i
) { printf("%d\n", data
[i
]); }