#include typedef int Item; #define key(A) (A) #define lt(A, B) (key(A) < key(B)) // less than #define le(A, B) (key(A) <= key(B)) // less than or equal to #define ge(A, B) (key(A) >= key(B)) // greater than or equal to #define gt(A, B) (key(A) > key(B)) // greater than void swap(Item a[], int i, int j) { Item temp = a[i]; a[i] = a[j]; a[j] = temp; } void insertionSort(Item items[], int lo, int hi) { for (int i = lo + 1; i <= hi; i++) { Item item = items[i]; int j = i; for (; j > lo && lt(item, items[j - 1]); j--) { items[j] = items[j - 1]; } items[j] = item; } } int main(void) { Item a[] = {42, 7, 19, 3, 88, 1}; int n = sizeof(a) / sizeof(a[0]); insertionSort(a, 0, n - 1); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } printf("\n"); return 0; }