我有一个关于此编码中的故障的快速问题。
当我运行这个程序并进入这个循环时(通过输入 1 作为数字),一切都很顺利,除了即使我进入++generalcounter1;
了循环体,它似乎并不是每次都在这个变量中添加一个循环播放。当变量 == 10 时,它永远不会运行它应该运行的消息。
请帮助我,我很沮丧!非常感谢您的建议!
抱歉,如果不清楚,我对这个网站以及编程都是新手。
while (number == 1){
int addend1;
int addend2;
int sum;
int answer1;
int generalcounter1 = 0;
int reply1;
++generalcounter1;
addend1 = 1 + rand() % 50;
addend2 = 1 + rand() % 50;
sum = (addend1 + addend2);
cout << "\nWhat is " << addend1 << " plus " << addend2 << "? ";
cin >> answer1;
if (answer1 == sum){
reply1 = winstatement();
}
else{
reply1 = losestatement();
}
if (generalcounter1 == 10){
if (rightanswers >= 8){
cout << "\nCongratulations, you are ready to go to the next level!\n" << endl;
}
else{
cout << "\nPlease ask your teacher for extra help.\n" << endl;
}
}
}