我正在尝试根据具有以下规则的投注系统来计算奖金,损失和利润:
这就是我所拥有的
int initialBet = 30;
int currentBet = initialBet;
int totalWinnings = 0;
int totalLosses = 0;
int totalProfit = 0;
int i = 0
do {
if (win) {
//you win back your bet + half your bet, i.e. bet=30, win=45, profit=15
}
else //loss
{
totalLosses += currentBet; //you lost your full current bet
currentBet = currentBet * 2; //Double your next bet to win back your money
}
i++
} while (i < 100);
totalProfit = totalWinnings + totalLosses;
在我的“胜利”场景中应该如何正确追踪这个?
答案 0 :(得分:1)
听起来你正在寻找这样的东西:
if (win) {
totalWinnings += (int)Math.Floor(currentBet * 1.5);
}
如果您正在尝试分析投注策略,那么当您获胜时,您似乎想要使用currentBet
执行某些操作,但您尚未在此处指定。
同样正如Grant Winney指出的那样,你可能想要像这样计算totalProfit
:
totalProfit = totalWinnings - totalLosses;