diff --git a/highscores.txt b/highscores.txt index 63a5728..e94b558 100644 --- a/highscores.txt +++ b/highscores.txt @@ -1,3 +1 @@ -krisp3;6987 -krisp2;4985 -krisp;3991 +krisp5;4991 diff --git a/numbers.c b/numbers.c index d02217d..c9f206c 100644 --- a/numbers.c +++ b/numbers.c @@ -18,10 +18,14 @@ // typedef int (*CompareFctType)(const void *arg1, const void *arg2); // vergleicht zwei Werte: ab: 1 a=b: 0 -int compareUnsignedInt(const void *a, const void *b) { - unsigned int x = *(unsigned int *)a; - unsigned int y = *(unsigned int *)b; - return (x < y) ? -1 : (x > y); +int compareUnsignedInt(const void *a, const void *b) { // generischer Zeiger + unsigned int x = *(unsigned int *)a; // Typumwandlung: void * → unsigned int * + unsigned int y = *(unsigned int *)b; // Wert wird durch *b in y gespeichert + if (x < y) + return -1; + if (x > y) + return 1; + return 0; } // numbers = createNumbers(numberOfElements); // es wird die angefragte Länge des Arrays übergeben