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.
230 lines
6.7 KiB
230 lines
6.7 KiB
#include <time.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "wwm.h"
|
|
|
|
// Deklaration aller Variablen
|
|
int runde = 0;
|
|
int geld = 0;
|
|
int frage = 0;
|
|
int useranswer;
|
|
|
|
int ceingabe();
|
|
|
|
|
|
// setzt Geldbetrag auf entsprechenden Wert
|
|
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;
|
|
}
|
|
|
|
// Berechnet zufällige Nummer für die Frage aus
|
|
int crandomNumber() {
|
|
srand(time(NULL));
|
|
frage = rand() % 10;
|
|
return frage;
|
|
|
|
}
|
|
|
|
// Überprüft Antwort auf 5 und Zahlen kleiner als 1 oder größer als 4
|
|
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();
|
|
}
|
|
}
|
|
|
|
// Eingabe mit Pürfung auf integer
|
|
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_easy[] = {
|
|
"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_easy[][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_easy[] = {
|
|
3, 2, 1, 2, 4, 2, 1, 3, 1, 2
|
|
};
|
|
|
|
|
|
const char* questions_medium[] = {
|
|
"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?",
|
|
"What is the largest bone in the human body?",
|
|
"In which year did the Titanic sink?",
|
|
"What is the capital city of Argentina?",
|
|
"In which year did World War II end?",
|
|
"What is the currency of Japan?"
|
|
};
|
|
|
|
const char* answers_medium[][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"},
|
|
{"Femur", "Sternum", "tibia", "fibula"},
|
|
{"1910", "1915", "1912", "1920"},
|
|
{"Brasilia", "La Plata", "Rosario", "Buenos Aires"},
|
|
{"1945", "1940", "1948", "1933"},
|
|
{"Yuan", "Yen", "Rupiah", "Rupee"}
|
|
};
|
|
|
|
int correctAnswer_medium[] = {
|
|
1, 3, 4, 2, 2, 1, 3, 4, 1, 2
|
|
};
|
|
|
|
const char* questions_hard[] = {
|
|
"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?",
|
|
"What is the capital city of Bhutan?",
|
|
"In mathematics, what is the name for a number that is not a prime number and has more than two factors?",
|
|
"Who is the Greek god of war and son of Zeus and Hera?",
|
|
"What is the chemical symbol for the element mercury?",
|
|
"What is the name of the largest moon of Jupiter?",
|
|
"Where did backgammon originate?"
|
|
};
|
|
|
|
const char* answers_hard[][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"},
|
|
{"prime number", "composite number", "fibonacci numbers", "perfect numbers"},
|
|
{"Herkules", "Hermes", "Ares", "Loki"},
|
|
{"Hg", "Ha", "Me", "My"},
|
|
{"Europa", "Titan", "Ganymede", "Io"},
|
|
{"Roman Empire", "Persia", "Greece", "Inka"}
|
|
};
|
|
|
|
int correctAnswer_hard[] = {
|
|
4, 1, 2, 1, 3, 2, 3, 1, 3, 2
|
|
};
|
|
|
|
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_easy[frage]);
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
printf("%d. %s \n", i + 1, answers_easy[frage][i]);
|
|
}
|
|
|
|
ceingabe();
|
|
|
|
|
|
if (useranswer == correctAnswer_easy[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, questions_medium[frage]);
|
|
for (int i = 0; i < 4; i++) {
|
|
printf("%d. %s \n", i + 1, answers_medium[frage][i]);
|
|
};
|
|
|
|
ceingabe();
|
|
|
|
|
|
if (useranswer == correctAnswer_medium[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, questions_hard[frage]);
|
|
for (int i = 0; i < 4; i++) {
|
|
printf("%d. %s \n", i + 1, answers_hard[frage][i]);
|
|
};
|
|
|
|
ceingabe();
|
|
|
|
|
|
if (useranswer == correctAnswer_hard[frage]) {
|
|
printf("That is correct!\n");
|
|
runde++;
|
|
setGeld(runde);
|
|
}
|
|
else {
|
|
printf("What a shame! That is wrong! \n You lost %d $ ", geld);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|