我目前无法让我的再滚轮在 100% 的时间内正常工作。有时它的作用是正确的,只会改变我选择的东西,但有时它似乎有自己的想法。这是我的代码中的一些片段。
Int main()
...
while (counter<13){
cout<< playName << " please roll the dice."<<endl;
system("pause");
roll();
reRoll();
reRoll();
score();}
void reRoll(){
cout<< playName << " please select which dice you would like to re-roll by entering
a y or n."<<endl;
cout<< "Would you like to re-roll die 1?";
cin>>dieOne;
cout<< "Would you like to re-roll die 2?";
cin>>dieTwo;
cout<< "Would you like to re-roll die 3?";
cin>>dieThree;
cout<< "Would you like to re-roll die 4?";
cin>>dieFour;
cout<< "Would you like to re-roll die 5?";
cin>>dieFive;
srand(static_cast<unsigned int>(time(0)));
const int dice = 6;
int die[6] = {1, 2, 3, 4, 5, 6};
if (dieOne=="y"){
int dice1Roll = (rand() % dice);
currentDice[0] = die[dice1Roll];}
if (dieOne!="y"){}
if (dieTwo=="y"){
int dice2Roll = (rand() % dice);
currentDice[1] = die[dice2Roll];}
if (dieTwo!="y"){}
if (dieThree=="y"){
int dice3Roll = (rand() % dice);
currentDice[2] = die[dice3Roll];}
if (dieThree!="y"){}
if (dieFour=="y"){
int dice4Roll = (rand() % dice);
currentDice[3] = die[dice4Roll];}
if (dieFour!="y"){}
if (dieFive=="y"){
int dice5Roll = (rand() % dice);
currentDice[4] = die[dice5Roll];}
if (dieFive!="y"){}
cout<<playName<<"'s die are now "<<currentDice[0]<<" "<<currentDice[1]<<" "
<<currentDice[2]<<" "<<currentDice[3]<<" "<<currentDice[4]<<endl;}