嗨IM 17,并试图教自己C++。对于我的第一个项目,我正在尝试写一个tic-tac-toe游戏,并与AI进行比赛。所以遇到问题的代码IM是这个tic-tac-toe while and ||
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循环有关。任何帮助表示赞赏。
这是一个例如,从书中的文字? – 2012-02-21 05:12:42
警告,您在初始化之前检查玩家! 在用户被问到之前,玩家可能会随机以'x'或'o'结尾!在使用它们之前,您必须初始化变量。 – abelenky 2012-02-21 05:13:00
CodingMastero这不是,它只是我想出了 – 2012-02-21 05:18:11