From 154874afda4a8df885e51c01f7681f04fb0b8e61 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sat, 9 Apr 2022 09:43:53 +0200 Subject: neue Verzeichnisstruktur --- insertsort.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 insertsort.c (limited to 'insertsort.c') diff --git a/insertsort.c b/insertsort.c deleted file mode 100644 index 1a30a1a..0000000 --- a/insertsort.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -#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; -} -- cgit v1.3