我正在尝试制作一个基于文本的角色扮演游戏,我正在实现diceroll功能:
int diceRoll(){
int n;
srand(time(0));
n = rand() % 4;
return n;
}
int main()
{
int RandNum = diceRoll();
cout<< " Randomly generated number: " + RandNum;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然而它输出了这个: