井字游戏。每当最后一行被填满时结束?

Tic-tac-toe game. ends whenever the last row is filled?

这是一款井字游戏。问题是如果最后一行被填满,游戏会打印 "Draw" 并结束,这应该只有在所有单元格都被填满时才会发生。我有什么错?!

http://pastebin.com/RZZn5wWe

The break statement terminates the execution of the nearest enclosing do, for, switch, or while statement in which it appears. Control passes to the statement that follows the terminated statement.

当您设置 empty_cell 变量时,您会在嵌套循环中使用中断。这样做你只退出第一个循环并在第二个循环中继续。这导致了您的问题。

将你的标志设置在循环之外,仅在需要时更改它。