diff --git a/highscores.txt b/highscores.txt index 5df6690..223b7c0 100644 --- a/highscores.txt +++ b/highscores.txt @@ -1,3 +1,9 @@ +thilo;19753 +thilo;14880 +thilo;14733 +player1;9956 +player2;4988 player1;4980 player_name;4980 +player2;4885 player1;3999 diff --git a/numbers.c b/numbers.c index 14edced..96f6138 100644 --- a/numbers.c +++ b/numbers.c @@ -73,11 +73,36 @@ unsigned int *createNumbers(unsigned int len) srand(time(NULL)); - for (unsigned int i = 0; i < len; i++) + /*for (unsigned int i = 0; i < len; i++) { array[i] = rand() % (2*len) + 1; } + */ + + TreeNode *root = NULL; + int isDuplicate; + unsigned int value; + unsigned int i = 0; + + srand(time(NULL)); + + while (i < len) + { + value = rand() % (2 * len) + 1; + + root = addToTree(root, &value, sizeof(unsigned int), compareFct, &isDuplicate); + + if (isDuplicate == 0) + { + array[i] = value; + i++; + } + // Bei Duplikat: nochmal versuchen, kein Inkrement + } + + clearTree(root); + position = rand() % len; diff --git a/stack.o b/stack.o index e90b588..3f73d64 100644 Binary files a/stack.o and b/stack.o differ