ランダム機能の使い方を学び終えたばかりなので、小さなカジノゲームを作ることにしました。double Money;ただし、私のコードは変数を更新しません。つまり、この変数に対して値を設定、加算、または減算することはできません。なぜこれが起こっているのかを判断するのに苦労しています。
これが私のコードです:
int main()
{
  double Money;//Variable Money;
  srand ( time(0) );
  int randomNumber;
  randomNumber = (1+(rand() % 10));
  cout << "\nEnter your Starting Money: ";
  int Guess;
  cin >> Money;
  cout << "Your Starting money is: " << Money;
  cout << "\nGuess the number between 1 and 10: ";
  start:
  cin >> Guess;
  if(Guess == randomNumber)
  {
    Money + 10;
    cout << "You were correct! The number was " << randomNumber << "!";
  }
  else
  {
    Money - 10;//Nothing Happens
    cout << "You were wrong! Your money is now: " << Money << "\nRetry Please: ";
    goto start;
  }
  char f;
  cin >> f;
  return 0;
}