Kommentare numbers.c

This commit is contained in:
Kristin 2025-12-15 16:39:02 +01:00
parent 16f3961eb4
commit 38ce259cbc
2 changed files with 9 additions and 7 deletions

View File

@ -1,3 +1 @@
krisp3;6987 krisp5;4991
krisp2;4985
krisp;3991

View File

@ -18,10 +18,14 @@
// typedef int (*CompareFctType)(const void *arg1, const void *arg2); // typedef int (*CompareFctType)(const void *arg1, const void *arg2);
// vergleicht zwei Werte: a<b: -1 a>b: 1 a=b: 0 // vergleicht zwei Werte: a<b: -1 a>b: 1 a=b: 0
int compareUnsignedInt(const void *a, const void *b) { int compareUnsignedInt(const void *a, const void *b) { // generischer Zeiger
unsigned int x = *(unsigned int *)a; unsigned int x = *(unsigned int *)a; // Typumwandlung: void * → unsigned int *
unsigned int y = *(unsigned int *)b; unsigned int y = *(unsigned int *)b; // Wert wird durch *b in y gespeichert
return (x < y) ? -1 : (x > y); if (x < y)
return -1;
if (x > y)
return 1;
return 0;
} }
// numbers = createNumbers(numberOfElements); // numbers = createNumbers(numberOfElements);
// es wird die angefragte Länge des Arrays übergeben // es wird die angefragte Länge des Arrays übergeben