Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- using namespace std;
- //===========================================================================
- //===========================================================================
- // Définissez ici votre structure
- struct JackPot { float credit; float mise; float gain; int roue; };
- {
- int roue[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++)
- {
- if (pointeur->tirage[i][0] == 0) // la case est vide
- {
- 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
- }
- 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 !" <<endl;
- }
- else {
- cout << "pas de chance" <<endl;
- }
- cout << "Votre argent: " << pointeur.credit << " - continuer ? (y|n) " <<endl;
- do
- {
- cin >> reponse;
- }
- while(reponse != "y" && reponse != "n");
- if (reponse == "n" || pointeur.credit == 0)
- {
- cout << "Fin" <<endl; // fin du jeu
- partie = !partie;
- }
- else
- {
- // on continue
- cout << "--- on continue ---" <<endl;
- cout << "Votre argent : " << pointeur.credit <<endl;
- }
- }
- return 0;
- }
- //===========================================================================
- //===========================================================================
- // Définissez ici vos fonctions
- //===========================================================================
- //===========================================================================
- //int main(int argc, char *argv[])
- //{
- /*****************************************/
- /* placez ici les appels à vos fonctions */
- /*****************************************/
- /**********/
- /* retour */
- /**********/
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement