合計値に乱数を追加する 2 つの関数があります。
問題は、関数を呼び出して合計を出力するたびに加算されないことです。2 を生成すると、合計が 2 であると表示されます。その後、もう一度呼び出して 5 を生成すると、合計が 5 であると表示され、加算されません (これが発生した場合は 7 になるはずです)。
ここではすべてがうまく見えます...
int human(int humanscore)
{
int diceRoll= rand() % 7;
cout << "player rolled: ";
humanscore+= diceRoll;
cout << diceRoll;
cout << "human score is: " << humanscore;
}
int computer(int compscore)
{
int diceRoll= rand() % 7;
cout << "computer rolled: ";
compscore+= diceRoll;
cout << diceRoll;
cout << "computer score is: " << compscore;
}