Advertisement
donirobertos

Untitled

Dec 13th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. void main()
  8. {
  9. setlocale(LC_ALL, "ru");
  10. srand(time(NULL));
  11. int stake = 0;
  12. int goal = 0;
  13. int trials = 0;
  14. int bets = 0;
  15. int wins = 0;
  16. int loss = 0;
  17. int cash = 0;
  18. int Rand = 0;
  19. int max = 0;
  20. double one = 0; // разделение вычисления % выигрышей по действиям, т.к. при записи в одно действие, получаю 0.
  21. double two = 0;
  22. double three = 0;
  23. double percent = 0;
  24. stake = 500;
  25. cash = stake;
  26. goal = 1000000;
  27. for (trials = 0; cash < goal; trials++)
  28. {
  29. Rand = rand() % 2;
  30.  
  31. if (Rand)
  32. {
  33. cash = cash * 2; //выигрыш
  34. wins++;
  35. }
  36. else
  37. {
  38. cash = cash / 2; // проигрыш
  39. loss++;
  40. }
  41. if (cash > max)
  42. {
  43. max = cash;
  44. }
  45.  
  46.  
  47. if (cash == 0)
  48. break;
  49.  
  50. }
  51. one = wins - loss;
  52. two = one / loss;
  53. three = two * 100;
  54. percent = three;
  55. if (cash > goal)
  56. {
  57. cout << "Победа, ура !" << endl;
  58. }
  59. else
  60. {
  61. cout << "К сожалению цель не достигнута" << endl;
  62. }
  63.  
  64. cout << "Начальная сумма = " << stake<< endl;
  65. cout << "цель = " << goal<< endl;
  66. cout << "Попытки = " << trials << endl;
  67. cout << "Выигрышные ставки = " << wins << endl;
  68. cout << "Проигрыши = " << loss << endl;
  69. cout <<"Максимальная сумма в течении игры = " << max<< endl;
  70. cout <<"Процент выигрышей = " << percent << endl;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement