Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- void main()
- {
- setlocale(LC_ALL, "ru");
- srand(time(NULL));
- int stake = 0;
- int goal = 0;
- int trials = 0;
- int bets = 0;
- int wins = 0;
- int loss = 0;
- int cash = 0;
- int Rand = 0;
- int max = 0;
- double one = 0; // разделение вычисления % выигрышей по действиям, т.к. при записи в одно действие, получаю 0.
- double two = 0;
- double three = 0;
- double percent = 0;
- stake = 500;
- cash = stake;
- goal = 1000000;
- for (trials = 0; cash < goal; trials++)
- {
- Rand = rand() % 2;
- if (Rand)
- {
- cash = cash * 2; //выигрыш
- wins++;
- }
- else
- {
- cash = cash / 2; // проигрыш
- loss++;
- }
- if (cash > max)
- {
- max = cash;
- }
- if (cash == 0)
- break;
- }
- one = wins - loss;
- two = one / loss;
- three = two * 100;
- percent = three;
- if (cash > goal)
- {
- cout << "Победа, ура !" << endl;
- }
- else
- {
- cout << "К сожалению цель не достигнута" << endl;
- }
- cout << "Начальная сумма = " << stake<< endl;
- cout << "цель = " << goal<< endl;
- cout << "Попытки = " << trials << endl;
- cout << "Выигрышные ставки = " << wins << endl;
- cout << "Проигрыши = " << loss << endl;
- cout <<"Максимальная сумма в течении игры = " << max<< endl;
- cout <<"Процент выигрышей = " << percent << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement