You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
5.3 KiB

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "wwm.h"
int runde = 0;
int geld = 0;
int frage = 0;
int useranswer;
int ceingabe();
int setGeld(int runde){
int Geldstufen[] = {0, 100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000};
geld = Geldstufen[runde];
return geld;
}
int crandomNumber() {
srand(time(NULL));
frage = rand() % 10;
return frage;
}
void ccheckAnswer(int useranswer) {
if (useranswer == 5) {
printf("That is a shame, but ok.\n");
printf("Congratulations! You have won %d $!", geld);
exit(0);
}
if (useranswer < 1 || useranswer > 4) {
printf("Please enter a number beetween 1 and 4 or enter 5 to end the game!\n");
ceingabe();
}
}
int ceingabe() {
printf("Your answer (1-4):");
int result = scanf("%d", &useranswer);
if (result == 0) {
printf("Please enter a number beetween 1 and 4 to answer or 5 to end the game!\n");
while (getchar() != '\n')
return ceingabe();
}
ccheckAnswer(useranswer);
return useranswer;
}
void wwm(){
printf("Welcome to ´Who wants to be a millionaire?´ \n");
printf("Choose your answer with the numbers 1-4! \n");
printf("If you want to stop and take the money, type in 5!\n");
const char* question[] = {
"Which planet is known as the `blue planet`?",
"What is the capital of Germany?",
"What is the largest desert in the world?",
"In which country would you find the Great Wall?",
"How many meters are in a kilometer?",
"How many colors are there in a rainbow?",
"What is the square root of 25?",
"Who painted the Mona Lisa?",
"What is the largest ocean on earth?",
"What is the largest planet in our solar system?"
};
const char* answers[][4] = {
{"Mars", "Venus", "Earth", "Jupiter"},
{"Munich", "Berlin", "Cologne", "Frankfurt am Main"},
{"Antarctica", "Sahara", "Gobi", "Arctica" },
{"USA", "China", "Russia", "Japan"},
{"100", "10", "1", "1000"},
{"6", "7", "8", "9"},
{"5", "25", "20", "10"},
{"Vincent van Gogh", "Pablo Picasso", "Leonardo da Vinci", "Michelangelo"},
{"Pacific Ocean", "Atlantic Ocean", "Arctic Ocean", "Indian Ocean"},
{"Merkur", "Jupiter", "Neptun", "Pluto"}
};
int correctAnswer[] = {
3, 2, 1, 2, 4, 2, 1, 3, 1, 2
};
const char* questions2[] = {
"In what year did the Berlin Wall fall?",
"What is the capital city of Brazil?",
"Who is known as the Father of Modern Physics?",
"What is the largest island in the world?",
"What is the chemical symbol for silver?"
};
const char* answers2[][4] = {
{"1989", "1998", "1994", "1990"},
{"Buenos Aires", "Sao Paulo", "Brasilia", "Rio de Janeiro"},
{"Thomas Edison", "Marie Curie", "Isaac Newton", "Albert Einstein"},
{"Australia", "Greenland", "Madascar", "Borneo"},
{"Au", "Ag", "Su", "Si"}
};
int correctAnswer2[] = {
1, 3, 4, 2, 2
};
const char* questions3[] = {
"What is the rarest blood type among humans?",
"In which year did Serena Williams win her first Grand Slam singles title?",
"In what year and in which city were the first modern Olympic Games held?",
"Benjamin Franklin was a key figure in the drafting of the United States Constitution. Which state did he represent during the Constitutional Convention in 1787?",
"What is the capital city of Bhutan?"
};
const char* answers3[][4] = {
{"A", "B", "0", "AB"},
{"1999", "1995", "2000", "2002"},
{"1894 in Rome, Italy", "1896 in Athens, Greece", "1898 in Madrid, Spain", "1890 in Istanbul, Turkey"},
{"Pennsylvania", "Oregon", "Texas", "Florida"},
{"Paro", "Punakha", "Thimphu", "Tongsa"}
};
int correctAnswer3[] = {
4, 1, 2, 1, 3
};
for (int r = 1; r <= 16; r++){
if (r == 16) {
printf("Congratulations ! You have won 1.000.000 $");
return;
}
if (r <= 5) {
printf("__________________________________________________ \n\n");
printf("You are at stage %d and have %d $\n", runde, geld);
crandomNumber();
printf("Question %d: %s\n", runde + 1, question[frage]);
for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers[frage][i]);
}
ceingabe();
if (useranswer == correctAnswer[frage]) {
printf("That is correct!\n");
runde++;
setGeld(runde);
}
else {
printf("That is a shame! That is wrong!\n You lost %d $", geld);
return;
}
}
if (r > 5 && r <= 10) {
printf("___________________________________________________________\n\n");
printf("You are at stage %d and have %d $\n", runde + 1, geld);
crandomNumber();
printf("Question %d: %s\n", runde + 1, questions2[frage]);
for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers2[frage][i]);
};
ceingabe();
if (useranswer == correctAnswer2[frage]) {
printf("That is correct!\n");
runde++;
setGeld(runde);
}
else {
printf("What a shame! That is wrong! \n You lost %d $ ", geld);
break;
}
}
if (r > 10 && r <= 15) {
printf("___________________________________________________________\n\n");
printf("You are at stage %d and have %d $\n", runde + 1, geld);
crandomNumber();
printf("Question %d: %s\n", runde + 1, questions3[frage]);
for (int i = 0; i < 4; i++) {
printf("%d. %s \n", i + 1, answers3[frage][i]);
};
ceingabe();
if (useranswer == correctAnswer3[frage]) {
printf("That is correct!\n");
runde++;
setGeld(runde);
}
else {
printf("What a shame! That is wrong! \n You lost %d $ ", geld);
break;
}
}
}
}