gpt4 book ai didi

c++ - 双输入验证 C++ 程序的问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:58:28 26 4
gpt4 key购买 nike

所以我想:

  1. 在 do while 循环中进行双输入验证
  2. 检查移动是否已经完成,是否为逻辑输入。 (#1-9)

我最初想到的是 if else 语句,但我不确定如何使用 else 语句回到循环的开始。

do
{
cout << "Interesting move, What is your next choice?: ";
cin >> play;
Pused[1] = play;
if(play != Pused[0] && play != cantuse[0] && play != cantuse[1] )
{
switch(play)
{
default:cout << "Your choice is incorrect\n\n";
break;
}
}
else
{ }
}
while(play != 1 && play != 2 && play != 3 && play != 4 && play != 5 && play != 6 && play != 7 && play != 8 && play != 9);
Dis_board(board);

最佳答案

使用“continue”关键字返回到循环的开始。

关于c++ - 双输入验证 C++ 程序的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13946150/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com