int a[8] = {4, 9, 17, 31, 12, 26, 5, 20}; void swap(int *x, int *y) { int t = *x; *x = *y; *y = t; } void sort(int n) { for (int i = 1; i < n; i++) { int j = i; while (j > 0 && a[j - 1] > a[j]) { swap(&a[j - 1], &a[j]); j--; } } } int main(void) { sort(8); return 0; }