Advertisement
Timtsa

Untitled

Jan 30th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. a.SetProability(30);
  2. int count = 0;
  3. for (int i = 0; i < 60; i++)
  4. {
  5. if (a.GetEvent())
  6. {
  7. count++;
  8. }
  9.  
  10. }
  11. cout << count << endl;
  12.  
  13.  
  14.  
  15. class RandomGenerator
  16. {
  17. public:
  18. void SetProability(int p)
  19. {
  20. probility = p;
  21. }
  22.  
  23.  
  24. bool GetEvent()
  25. {
  26. int check = rand() % 60;
  27. if (check<=probility)
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33.  
  34.  
  35. private:
  36. int probility = 0;
  37.  
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement