Advertisement
luwna30

Untitled

Nov 22nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. struct JackPot
  6. {
  7. int roues[3] = 0;
  8. float credit = 100;
  9. float mise;
  10. float gain;
  11. int tirage[100][3] = 0;
  12.  
  13. }
  14.  
  15.  
  16. int random_int(int min, int max)
  17. {
  18. return min + rand() % (max - min);
  19. }
  20.  
  21.  
  22. void tirage(JackPot *pointeur)
  23. {
  24. for (int r = 0; r < 3; r++)
  25. {
  26. int min = 1;
  27. int max = 5;
  28. int nombre = 2 * random_int(min, max);
  29.  
  30. pointeur->roues[r] = nombre;
  31.  
  32. // on enregistre les tirages
  33.  
  34. for (int i = 0; i < 100; i++)
  35. {
  36. // cette case est vide
  37.  
  38. if (pointeur->tirage[i][0] == 0)
  39. {
  40. pointeur->tirage[i][r] = nombre;
  41. }
  42.  
  43. }
  44.  
  45. }
  46.  
  47. }
  48.  
  49.  
  50.  
  51. void mise(JackPot *pointeur)
  52. {
  53. cout << "Donnez votre mise: " <<endl;
  54. // on demande une mise - si elle n'est pas bonne, on recommence
  55.  
  56. do
  57. {
  58. cin >> pointeur->mise;
  59. }
  60.  
  61. while(pointeur->mise == 0 || pointeur->mise > pointeur->credit);
  62.  
  63. // quand c'est bon on continue
  64. pointeur->credit -= pointeur->mise; // argent qu'il reste après la mise
  65. }
  66.  
  67.  
  68.  
  69. int main()
  70. {
  71. srand(time(NULL));
  72. JackPot pointeur;
  73. bool partie = true;
  74.  
  75. // Boucle infinie du jeu
  76. while (partie) {
  77. mise(&);
  78. tirage(&pointeur);
  79.  
  80.  
  81. if (pointeur.roues[0] == pointeur.roues[1] && pointeur.roues[0] == pointeur.roues[2])
  82. {
  83. pointeur.credit += pointeur.mise * 10;
  84. cout << "mise multipliée par 10 !" <<endl;
  85.  
  86. }
  87.  
  88. else if (pointeur.roues[0] == pointeur.roues[1] || pointeur.roues[0] == pointeur.roues[2] || pointeur.roues[1] == pointeur.roues[2])
  89. {
  90. pointeur.credit += pointeur.mise * 2;
  91. cout << "mise doublée !" << std::endl;
  92. } else {
  93. cout << "pas de chance !" << std::endl;
  94. }
  95.  
  96. cout << "Votre argent: " << pointeur.credit << " - continuer ? (y|n) " << std::endl;
  97. string rep;
  98.  
  99. do
  100. {
  101. cin >> rep;
  102. }
  103.  
  104. while(rep != "y" && rep != "n");
  105.  
  106. if (rep == "n" || pointeur.credit == 0)
  107. {
  108. // fin deu jeu
  109.  
  110. cout << "Fin" <<endl;
  111. partie = !partie;
  112. }
  113.  
  114. else
  115. {
  116. // on continue
  117. cout << "--- on continue ---" <<endl;
  118. cout << "Votre argent : " << pointeur.credit <<endl;
  119.  
  120. }
  121.  
  122. }
  123.  
  124. return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement