나는 게임 "쓰레기"에 대한 코드를 작성하고 있습니다.음수 값을 양수 카운터 부분으로 변환했습니다.
if 문이 있습니다. if 문에서 사용하고있는 변수는 is_win_or_loss_or_point (dice_sum)에서 반환됩니다. 이 함수는 합계가 7 또는 11이면 1을 반환하고, 합이 2,3 또는 12이면 0을 반환합니다. 이러한 값 중 하나가 아니면 -1을 반환합니다.
-1을 반환하는 합계를 얻으면 (즉 6) point_value에 값 -1이 할당됩니다. point_value는 if (point_value == 0)에 도달하면 -1 값을 유지합니다. 그러나 else (point_value == 1)을 실행하면 디버깅에서 (긍정적 인 1로 간다) else 문을 계속 수행하는 대신 else를 계속 진행합니다.
int main()
{
balance=get_bank_balance();
while (balance > 0)
{
wager=get_wager_amount();
wager=check_wager_amount(wager,balance);
printf("Wager %.2lf\n",wager);
roll1=roll_dice();
roll2=roll_dice();
dice_sum=calculate_sum_dice(roll1,roll2);
point_value=is_win_loss_or_point(dice_sum);
if (point_value == 0)
{
printf("You lose\n");
new_balance=adjust_bank_balance(balance,wager,point_value);
printf("Your current balance is %.2lf\n",new_balance);
}
else if (point_value = 1) // **point of interest**
{
printf("You win\n");
new_balance=adjust_bank_balance(balance,wager,point_value);
printf("Your current balance is %.2lf\n",new_balance);
}
else
{
roll3=roll_dice();
roll4=roll_dice();
dice_sum2=calculate_sum_dice(roll3,roll4);
point_loss=is_point_loss_or_neither(dice_sum2,dice_sum);
new_balance=adjust_bank_balance(balance,wager,point_loss);
printf("Your current balance is %.2lf\n",new_balance);
}
balance=new_balance;
}
}
뭔가를 놓친 경우 언제든지 추가 정보를 요청하십시오.
가 나는 C-전문가 모르겠지만, 다른 안 원하는 경우 (point_value == 1) –
= 대 ==, 고전적인 오래된 . –