shellsort
#include <stdio.h> void shellsort(int a[], int n, int delt) { int i; for(i = delt; i+delt <= n; i ++) { int temp = a[i]; int j = i - delt; while(temp < a[j]) { a[j + delt] = a[j]; j = j - delt; } a[j + delt] = temp; } } void mainsort(int a[], int n, int delt[], int r) { int i; for(i = 0; i < r; i++) { shellsort(a, n, delt[i]); } } int main(void) { int i; int a[4] = {5, 3, 6, 8}; int delt[2] = {2, 1}; mainsort(a, 4, delt, 2); for(i = 0; i < 4; i++) printf("%d ", a[i]); printf("\n"); }