#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "util.h"

typedef int T;

void
insertsort(T a[], size_t n)
{
	for ( size_t i = 1; i < n; ++i ) {
		size_t  j     = i;
		const T value = a[i];

		for ( ; j > 0 && a[j - 1] > value; --j )
			a[j] = a[j - 1];

		a[j] = value;
	}
}

int
main(void)
{
	T a[10];

	srand(time(NULL));
	for ( size_t i = 0; i != NELEM(a); ++i )
		a[i] = rand() % 100;

	insertsort(a, NELEM(a));

	for ( size_t i = 0; i != NELEM(a); ++i )
		printf("%d ", a[i]);
	putchar('\n');
	return EXIT_SUCCESS;
}
