Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- struct JackPot
- {
- int roues[3] = 0;
- float credit = 100;
- float mise;
- float gain;
- int tirage[100][3] = 0;
- }
- int random_int(int min, int max)
- {
- return min + rand() % (max - min);
- }
- void tirage(JackPot *pointeur)
- {
- for (int r = 0; r < 3; r++)
- {
- int min = 1;
- int max = 5;
- int nombre = 2 * random_int(min, max);
- pointeur->roues[r] = nombre;
- // on enregistre les tirages
- for (int i = 0; i < 100; i++)
- {
- // cette case est vide
- if (pointeur->tirage[i][0] == 0)
- {
- pointeur->tirage[i][r] = nombre;
- }
- }
- }
- }
- void mise(JackPot *pointeur)
- {
- cout << "Donnez votre mise: " <<endl;
- // on demande une mise - si elle n'est pas bonne, on recommence
- do
- {
- cin >> pointeur->mise;
- }
- while(pointeur->mise == 0 || pointeur->mise > pointeur->credit);
- // quand c'est bon on continue
- pointeur->credit -= pointeur->mise; // argent qu'il reste après la mise
- }
- int main()
- {
- srand(time(NULL));
- JackPot pointeur;
- bool partie = true;
- // Boucle infinie du jeu
- while (partie) {
- mise(&);
- tirage(&pointeur);
- if (pointeur.roues[0] == pointeur.roues[1] && pointeur.roues[0] == pointeur.roues[2])
- {
- pointeur.credit += pointeur.mise * 10;
- cout << "mise multipliée par 10 !" <<endl;
- }
- else if (pointeur.roues[0] == pointeur.roues[1] || pointeur.roues[0] == pointeur.roues[2] || pointeur.roues[1] == pointeur.roues[2])
- {
- pointeur.credit += pointeur.mise * 2;
- cout << "mise doublée !" << std::endl;
- } else {
- cout << "pas de chance !" << std::endl;
- }
- cout << "Votre argent: " << pointeur.credit << " - continuer ? (y|n) " << std::endl;
- string rep;
- do
- {
- cin >> rep;
- }
- while(rep != "y" && rep != "n");
- if (rep == "n" || pointeur.credit == 0)
- {
- // fin deu jeu
- cout << "Fin" <<endl;
- partie = !partie;
- }
- else
- {
- // on continue
- cout << "--- on continue ---" <<endl;
- cout << "Votre argent : " << pointeur.credit <<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement