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

1 year ago
1 year ago
  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "wwm.h"
  5. // Deklaration aller Variablen
  6. int runde = 0;
  7. int geld = 0;
  8. int frage = 0;
  9. int useranswer;
  10. int ceingabe();
  11. // setzt Geldbetrag auf entsprechenden Wert
  12. int setGeld(int runde){
  13. int Geldstufen[] = {0, 100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000};
  14. geld = Geldstufen[runde];
  15. return geld;
  16. }
  17. // Berechnet zufällige Nummer für die Frage aus
  18. int crandomNumber() {
  19. srand(time(NULL));
  20. frage = rand() % 10;
  21. return frage;
  22. }
  23. // Überprüft Antwort auf 5 und Zahlen kleiner als 1 oder größer als 4
  24. void ccheckAnswer(int useranswer) {
  25. if (useranswer == 5) {
  26. printf("That is a shame, but ok.\n");
  27. printf("Congratulations! You have won %d $!", geld);
  28. exit(0);
  29. }
  30. if (useranswer < 1 || useranswer > 4) {
  31. printf("Please enter a number beetween 1 and 4 or enter 5 to end the game!\n");
  32. ceingabe();
  33. }
  34. }
  35. // Eingabe mit Pürfung auf integer
  36. int ceingabe() {
  37. printf("Your answer (1-4):");
  38. int result = scanf("%d", &useranswer);
  39. if (result == 0) {
  40. printf("Please enter a number beetween 1 and 4 to answer or 5 to end the game!\n");
  41. while (getchar() != '\n')
  42. return ceingabe();
  43. }
  44. ccheckAnswer(useranswer);
  45. return useranswer;
  46. }
  47. void wwm(){
  48. printf("Welcome to Who wants to be a millionaire? \n");
  49. printf("Choose your answer with the numbers 1-4! \n");
  50. printf("If you want to stop and take the money, type in 5!\n");
  51. const char* question_easy[] = {
  52. "Which planet is known as the `blue planet`?",
  53. "What is the capital of Germany?",
  54. "What is the largest desert in the world?",
  55. "In which country would you find the Great Wall?",
  56. "How many meters are in a kilometer?",
  57. "How many colors are there in a rainbow?",
  58. "What is the square root of 25?",
  59. "Who painted the Mona Lisa?",
  60. "What is the largest ocean on earth?",
  61. "What is the largest planet in our solar system?"
  62. };
  63. const char* answers_easy[][4] = {
  64. {"Mars", "Venus", "Earth", "Jupiter"},
  65. {"Munich", "Berlin", "Cologne", "Frankfurt am Main"},
  66. {"Antarctica", "Sahara", "Gobi", "Arctica" },
  67. {"USA", "China", "Russia", "Japan"},
  68. {"100", "10", "1", "1000"},
  69. {"6", "7", "8", "9"},
  70. {"5", "25", "20", "10"},
  71. {"Vincent van Gogh", "Pablo Picasso", "Leonardo da Vinci", "Michelangelo"},
  72. {"Pacific Ocean", "Atlantic Ocean", "Arctic Ocean", "Indian Ocean"},
  73. {"Merkur", "Jupiter", "Neptun", "Pluto"}
  74. };
  75. int correctAnswer_easy[] = {
  76. 3, 2, 1, 2, 4, 2, 1, 3, 1, 2
  77. };
  78. const char* questions_medium[] = {
  79. "In what year did the Berlin Wall fall?",
  80. "What is the capital city of Brazil?",
  81. "Who is known as the Father of Modern Physics?",
  82. "What is the largest island in the world?",
  83. "What is the chemical symbol for silver?",
  84. "What is the largest bone in the human body?",
  85. "In which year did the Titanic sink?",
  86. "What is the capital city of Argentina?",
  87. "In which year did World War II end?",
  88. "What is the currency of Japan?"
  89. };
  90. const char* answers_medium[][4] = {
  91. {"1989", "1998", "1994", "1990"},
  92. {"Buenos Aires", "Sao Paulo", "Brasilia", "Rio de Janeiro"},
  93. {"Thomas Edison", "Marie Curie", "Isaac Newton", "Albert Einstein"},
  94. {"Australia", "Greenland", "Madascar", "Borneo"},
  95. {"Au", "Ag", "Su", "Si"},
  96. {"Femur", "Sternum", "tibia", "fibula"},
  97. {"1910", "1915", "1912", "1920"},
  98. {"Brasilia", "La Plata", "Rosario", "Buenos Aires"},
  99. {"1945", "1940", "1948", "1933"},
  100. {"Yuan", "Yen", "Rupiah", "Rupee"}
  101. };
  102. int correctAnswer_medium[] = {
  103. 1, 3, 4, 2, 2, 1, 3, 4, 1, 2
  104. };
  105. const char* questions_hard[] = {
  106. "What is the rarest blood type among humans?",
  107. "In which year did Serena Williams win her first Grand Slam singles title?",
  108. "In what year and in which city were the first modern Olympic Games held?",
  109. "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?",
  110. "What is the capital city of Bhutan?",
  111. "What is the capital city of Bhutan?",
  112. "In mathematics, what is the name for a number that is not a prime number and has more than two factors?",
  113. "Who is the Greek god of war and son of Zeus and Hera?",
  114. "What is the chemical symbol for the element mercury?",
  115. "What is the name of the largest moon of Jupiter?",
  116. "Where did backgammon originate?"
  117. };
  118. const char* answers_hard[][4] = {
  119. {"A", "B", "0", "AB"},
  120. {"1999", "1995", "2000", "2002"},
  121. {"1894 in Rome, Italy", "1896 in Athens, Greece", "1898 in Madrid, Spain", "1890 in Istanbul, Turkey"},
  122. {"Pennsylvania", "Oregon", "Texas", "Florida"},
  123. {"Paro", "Punakha", "Thimphu", "Tongsa"},
  124. {"prime number", "composite number", "fibonacci numbers", "perfect numbers"},
  125. {"Herkules", "Hermes", "Ares", "Loki"},
  126. {"Hg", "Ha", "Me", "My"},
  127. {"Europa", "Titan", "Ganymede", "Io"},
  128. {"Roman Empire", "Persia", "Greece", "Inka"}
  129. };
  130. int correctAnswer_hard[] = {
  131. 4, 1, 2, 1, 3, 2, 3, 1, 3, 2
  132. };
  133. for (int r = 1; r <= 16; r++){
  134. if (r == 16) {
  135. printf("Congratulations ! You have won 1.000.000 $");
  136. return;
  137. }
  138. if (r <= 5) {
  139. printf("__________________________________________________ \n\n");
  140. printf("You are at stage %d and have %d $\n", runde, geld);
  141. crandomNumber();
  142. printf("Question %d: %s\n", runde + 1, question_easy[frage]);
  143. for (int i = 0; i < 4; i++) {
  144. printf("%d. %s \n", i + 1, answers_easy[frage][i]);
  145. }
  146. ceingabe();
  147. if (useranswer == correctAnswer_easy[frage]) {
  148. printf("That is correct!\n");
  149. runde++;
  150. setGeld(runde);
  151. }
  152. else {
  153. printf("That is a shame! That is wrong!\n You lost %d $", geld);
  154. return;
  155. }
  156. }
  157. if (r > 5 && r <= 10) {
  158. printf("___________________________________________________________\n\n");
  159. printf("You are at stage %d and have %d $\n", runde + 1, geld);
  160. crandomNumber();
  161. printf("Question %d: %s\n", runde + 1, questions_medium[frage]);
  162. for (int i = 0; i < 4; i++) {
  163. printf("%d. %s \n", i + 1, answers_medium[frage][i]);
  164. };
  165. ceingabe();
  166. if (useranswer == correctAnswer_medium[frage]) {
  167. printf("That is correct!\n");
  168. runde++;
  169. setGeld(runde);
  170. }
  171. else {
  172. printf("What a shame! That is wrong! \n You lost %d $ ", geld);
  173. break;
  174. }
  175. }
  176. if (r > 10 && r <= 15) {
  177. printf("___________________________________________________________\n\n");
  178. printf("You are at stage %d and have %d $\n", runde + 1, geld);
  179. crandomNumber();
  180. printf("Question %d: %s\n", runde + 1, questions_hard[frage]);
  181. for (int i = 0; i < 4; i++) {
  182. printf("%d. %s \n", i + 1, answers_hard[frage][i]);
  183. };
  184. ceingabe();
  185. if (useranswer == correctAnswer_hard[frage]) {
  186. printf("That is correct!\n");
  187. runde++;
  188. setGeld(runde);
  189. }
  190. else {
  191. printf("What a shame! That is wrong! \n You lost %d $ ", geld);
  192. break;
  193. }
  194. }
  195. }
  196. }