Advertisement
luwna30

Untitled

Nov 22nd, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <cmath>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. //===========================================================================
  10. //===========================================================================
  11.  
  12. // Définissez ici votre structure
  13.  
  14. struct JackPot { float credit; float mise; float gain; int roue; };
  15.  
  16. {
  17. int roue[3] = 0;
  18. float credit = 100;
  19. float mise;
  20. float gain;
  21. int tirage[100][3] = 0;
  22. }
  23.  
  24.  
  25.  
  26. int random_int(int min, int max)
  27. {
  28. return min + rand() % (max - min);
  29. }
  30.  
  31.  
  32.  
  33. void tirage(JackPot *pointeur)
  34. {
  35. for (int r = 0; r < 3; r++)
  36. {
  37. int min = 1;
  38. int max = 5;
  39. int nombre = 2 * random_int(min, max);
  40.  
  41. pointeur->roues[r] = nombre;
  42.  
  43. // on enregistre les tirages
  44.  
  45. for (int i = 0; i < 100; i++)
  46. {
  47. if (pointeur->tirage[i][0] == 0) // la case est vide
  48. {
  49. pointeur->tirage[i][r] = nombre;
  50. }
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }
  57.  
  58.  
  59.  
  60. void mise(JackPot *pointeur)
  61. {
  62. cout << "Donnez votre mise: " <<endl;
  63. // on demande une mise - si elle n'est pas bonne, on recommence
  64.  
  65. do
  66. {
  67. cin >> pointeur->mise;
  68. }
  69.  
  70. while(pointeur->mise == 0 || pointeur->mise > pointeur->credit);
  71.  
  72. // quand c'est bon on continue
  73. pointeur->credit -= pointeur->mise; // argent qu'il reste après la mise
  74. }
  75.  
  76.  
  77.  
  78. while (partie)
  79. {
  80. mise (&);
  81. tirage (&pointeur);
  82.  
  83.  
  84. if (pointeur.roues[0] == pointeur.roues[1] && pointeur.roues[0] == pointeur.roues[2])
  85. {
  86. pointeur.credit += pointeur.mise * 10;
  87. cout << "mise multipliée par 10 !" <<endl;
  88.  
  89. }
  90.  
  91.  
  92. else if (pointeur.roues[0] == pointeur.roues[1] || pointeur.roues[0] == pointeur.roues[2] || pointeur.roues[1] == pointeur.roues[2])
  93. {
  94. pointeur.credit += pointeur.mise * 2;
  95. cout << "mise doublée !" <<endl;
  96. }
  97.  
  98.  
  99. else {
  100. cout << "pas de chance" <<endl;
  101. }
  102.  
  103. cout << "Votre argent: " << pointeur.credit << " - continuer ? (y|n) " <<endl;
  104.  
  105.  
  106. do
  107. {
  108. cin >> reponse;
  109. }
  110.  
  111. while(reponse != "y" && reponse != "n");
  112.  
  113. if (reponse == "n" || pointeur.credit == 0)
  114. {
  115. cout << "Fin" <<endl; // fin du jeu
  116. partie = !partie;
  117. }
  118.  
  119.  
  120. else
  121. {
  122. // on continue
  123. cout << "--- on continue ---" <<endl;
  124. cout << "Votre argent : " << pointeur.credit <<endl;
  125.  
  126. }
  127.  
  128. }
  129.  
  130. return 0;
  131. }
  132.  
  133.  
  134.  
  135.  
  136. //===========================================================================
  137. //===========================================================================
  138.  
  139. // Définissez ici vos fonctions
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. //===========================================================================
  147. //===========================================================================
  148.  
  149. //int main(int argc, char *argv[])
  150. //{
  151. /*****************************************/
  152. /* placez ici les appels à vos fonctions */
  153. /*****************************************/
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. /**********/
  161. /* retour */
  162. /**********/
  163.  
  164.  
  165. return EXIT_SUCCESS;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement