このような状況でgoto okを使用している場合、私は知っておきたいのですか?あなたはより良い解決策を提案できますか?私はcicleの間に2番目にする唯一のものを見ますが、それから2回 "makeMove"を呼び出す必要があります。このような状況でgotoを使うことができますか?
void BoardView::startGame()
{
int currStep=0;
int x,y;
while (board_->isWin()==none)
{
currStep++;
show();
wrong:
std::cout << " Player " << (currStep%2==0 ? 1 : 2) << ": ";
std::cin >> x;
y=x%10;
x/=10;
if (!board_->makeMove(x,y,(currStep%2==0 ? cross : zero)))
{
std::cout << "Wrong move! Try again.\n";
goto wrong;
}
}
}
ループまたは別の関数。 – PlasmaHH
gotoを使用しないでください。 –
@PlasmaHHループ*と*は別個の機能です。入力は実際に別の関数に組み込む必要があります。 –