From 6a8e240d2510a69b3b4b31ecefdeddd1f5774dd1 Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Mon, 5 Feb 2024 23:33:18 +0100 Subject: [PATCH] =?UTF-8?q?Funktion=20f=C3=BCr=20zuf=C3=A4llige=20Frage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timequiz.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/timequiz.c b/src/timequiz.c index f3931e9..28f828b 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -54,8 +54,13 @@ void timequiz() { memset(askedQuestions, 0, sizeof(askedQuestions)); srand((unsigned int)time(NULL)); +} int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { + int questionIndex; + do { + questionIndex = rand() % totalQuestions; + } while (askedQuestions[questionIndex] == 1); + return questionIndex; } -}