|
@ -8,6 +8,7 @@ |
|
|
#define ASKED_QUESTIONS 40 |
|
|
#define ASKED_QUESTIONS 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Funktionen des Codes |
|
|
void timequiz(); |
|
|
void timequiz(); |
|
|
|
|
|
|
|
|
int getRandomQuestionIndex(int askedQuestions[], int totalQuestions); |
|
|
int getRandomQuestionIndex(int askedQuestions[], int totalQuestions); |
|
@ -18,8 +19,11 @@ void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalC |
|
|
|
|
|
|
|
|
int isValidAnswer(int userAnswer); |
|
|
int isValidAnswer(int userAnswer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void timequiz() { |
|
|
void timequiz() { |
|
|
|
|
|
|
|
|
|
|
|
//Willkommensnachricht |
|
|
printf("Welcome to our Time Quiz!\n"); |
|
|
printf("Welcome to our Time Quiz!\n"); |
|
|
printf("You have 60 seconds to answer the questions. Have fun!\n"); |
|
|
printf("You have 60 seconds to answer the questions. Have fun!\n"); |
|
|
|
|
|
|
|
@ -132,7 +136,7 @@ void timequiz() { |
|
|
correctAnswers[i] = 4; |
|
|
correctAnswers[i] = 4; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Variablen für das Spiel |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalAnsweredQuestions = 0; |
|
|
int totalAnsweredQuestions = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
@ -145,6 +149,7 @@ void timequiz() { |
|
|
memset(askedQuestions, 0, sizeof(askedQuestions)); |
|
|
memset(askedQuestions, 0, sizeof(askedQuestions)); |
|
|
srand((unsigned int)time(NULL)); |
|
|
srand((unsigned int)time(NULL)); |
|
|
|
|
|
|
|
|
|
|
|
//While-Schleife für Spielausführung |
|
|
while (elapsedTime < 60 && totalAnsweredQuestions < totalQuestions) { |
|
|
while (elapsedTime < 60 && totalAnsweredQuestions < totalQuestions) { |
|
|
int questionIndex = getRandomQuestionIndex(askedQuestions, totalQuestions); |
|
|
int questionIndex = getRandomQuestionIndex(askedQuestions, totalQuestions); |
|
|
askedQuestions[questionIndex] = 1; |
|
|
askedQuestions[questionIndex] = 1; |
|
@ -169,6 +174,7 @@ void timequiz() { |
|
|
elapsedTime = (int)difftime(currentTime, startTime); |
|
|
elapsedTime = (int)difftime(currentTime, startTime); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Endnachricht |
|
|
printf("\nQuiz finished!\n"); |
|
|
printf("\nQuiz finished!\n"); |
|
|
printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); |
|
|
printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); |
|
|
} |
|
|
} |
|
|