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.

70 lines
1.5 KiB

  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "wwm.h"
  5. int runde = 0;
  6. int geld = 0;
  7. int frage = 0;
  8. int useranswer;
  9. int setGeld(int runde){
  10. int Geldstufen[] = {0, 100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000};
  11. geld = Geldstufen[runde];
  12. return geld;
  13. }
  14. void wwm(){
  15. printf("Welcome to ´Who wants to be a millionaire?´ \n");
  16. const char* question[] = {
  17. "Which planet is known as the `blue planet`?",
  18. "What is the capital of Germany?",
  19. "What is the largest desert in the world?",
  20. "In which country would you find the Great Wall?",
  21. "How many meters are in a kilometer?"
  22. };
  23. const char* answers[][4] = {
  24. {"Mars", "Venus", "Earth", "Jupiter"},
  25. {"Munich", "Berlin", "Cologne", "Frankfurt am Main"},
  26. {"Antarctica", "Sahara", "Gobi", "Arctica" },
  27. {"USA", "China", "Russia", "Japan"},
  28. {"100", "10", "1", "1000"}
  29. };
  30. int correctAnswer[] = {
  31. 3, 2, 1, 2, 4
  32. };
  33. for (int r = 1; r <= 15; r++){
  34. printf("You are at stage %d and have %d $\n", runde, geld);
  35. srand(time(0));
  36. int frage = rand() % 5;
  37. printf("Question %d: %s\n", runde + 1, question[frage]);
  38. for (int i = 0; i < 4; i++) {
  39. printf("%d. %s \n", i + 1, answers[frage][i]);
  40. int useranswer;
  41. printf("Your answer (1-4):");
  42. scanf("%d", &useranswer);
  43. if (useranswer == correctAnswer[frage]) {
  44. printf("That is correct!\n");
  45. runde++;
  46. setGeld(runde);
  47. }
  48. else {
  49. printf("What a shame! That is wrong!\n");
  50. }
  51. }
  52. return;
  53. }
  54. }