Advertisement
Guest User

Untitled

a guest
Apr 4th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. #define _GAME_MAX_ 10000
  6. #define _VOITURE_ 1
  7. #define _CHEVRE_ 0
  8.  
  9. // Main
  10. void main() {
  11.  
  12. const bool portes[3] = {_CHEVRE_, _VOITURE_, _CHEVRE_};
  13.  
  14. int victoire = 0;
  15. int defaite = 0;
  16.  
  17. int porteChoisie;
  18. int porteRestante;
  19.  
  20. // Initialize random seed
  21. srand(time(NULL));
  22.  
  23. for ( int i = 0; i < _GAME_MAX_; ++i )
  24. {
  25. porteChoisie = portes[rand() % 3]; // Generate a number between 0 and 2
  26. porteRestante = porteChoisie ? _CHEVRE_ : _VOITURE_;
  27.  
  28. if ( porteRestante )
  29. victoire++;
  30.  
  31. if ( porteChoisie )
  32. defaite++;
  33. }
  34.  
  35. std::cout << victoire << '\n' << defaite;
  36. std::cin >> victoire;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement