嗨,我 17 岁,正在尝试自学 C++。对于我的第一个项目之一,我正在尝试编写井字游戏并与 AI 对战。所以我遇到问题的代码是这样的
main() {
char player, computer;
while (player != 'x' || player != 'o' )
{
cout << "do you want to be x or o?";
cin >> player;
};
if (player == 'x' ) computer == 'o';
else computer == 'x';
cout << "player is: " << player << endl << "computer is: " << computer ;
cout << computer;
};
我收到消息“你想成为 x 还是 o?”,但随后我输入 x 或 o,它不断重复相同的问题。我认为这与while循环有关。任何帮助表示赞赏。