Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- #define _GAME_MAX_ 10000
- #define _VOITURE_ 1
- #define _CHEVRE_ 0
- // Main
- void main() {
- const bool portes[3] = {_CHEVRE_, _VOITURE_, _CHEVRE_};
- int victoire = 0;
- int defaite = 0;
- int porteChoisie;
- int porteRestante;
- // Initialize random seed
- srand(time(NULL));
- for ( int i = 0; i < _GAME_MAX_; ++i )
- {
- porteChoisie = portes[rand() % 3]; // Generate a number between 0 and 2
- porteRestante = porteChoisie ? _CHEVRE_ : _VOITURE_;
- if ( porteRestante )
- victoire++;
- if ( porteChoisie )
- defaite++;
- }
- std::cout << victoire << '\n' << defaite;
- std::cin >> victoire;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement