난 무작위 기능을 사용하는 법을 배우기 만 했으므로 나는 작은 카지노 게임을 만들기로 결정했습니다. 그러나 내 코드는 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;
}
변수를 설정하지 않고'Money = Money + 10' 시도 –