循环没有继续无法弄清楚为什么

loops are not continuing can't figure out why

嘿,我这里有这个程序

#include <iostream>

using namespace std;

int main()
{
  int MyNum;
  int ComNum;
  MyNum = 5;

   do {
     cout << "Enter a whole number between 1 and 10: ";
     cin >> ComNum;
     if (ComNum > MyNum) {
       cout << "Sorry that is incorrect (Hint: too high)";
     }
     if (ComNum < MyNum) {
       cout << "Sorry that is incorrect (Hint: too low)";
       cin >> ComNum;
     }
   } while(MyNum != ComNum);
   cout << "Correct"
}

而且我不明白为什么它不会继续 运行 在第一个错误答案之后我确定我遗漏了一些小而愚蠢的东西 (P.S.) 这是如果你不能从代码中分辨出来,请猜我的数字游戏

只需删除 IF 中的 cin >> ComNum; 并修复编译器错误 cout << "Correct";

缺少分号在更正后出现错误:

#include <iostream>

using namespace std;

int main()
{
  int MyNum;
  int ComNum;
  MyNum = 5;

   do {
     cout << "Enter a whole number between 1 and 10: ";
     cin >> ComNum;
     if (ComNum > MyNum) {
       cout << "Sorry that is incorrect (Hint: too high)";
     }
     if (ComNum < MyNum) {
       cout << "Sorry that is incorrect (Hint: too low)";
       cin >> ComNum;
     }
   } while(MyNum != ComNum);
   cout << "Correct";
}

正如其他人所说,第二个cin >> ComNum; 是不必要的,尽管它在 https://www.onlinegdb.com/online_c++_compiler 上工作