if语句中的多个互斥条件

Multiple, exclusive, conditions in an if statement

本文关键字:条件 语句 if      更新时间:2024-05-10

if语句中的前两个语句之一为false,但我希望前两个声明都为false,以便代码不运行。请帮忙。

void change(Shore* left, Shore* right, int ex, int can) {
if (((ex!=left->lastMove[0]) && (can!=left->lastMove[1])) && (left->hasBoat)) {

我还尝试了下面的代码,但也不起作用

if ((ex!=left->lastMove[0] && can!=left->lastMove[1]) && left->hasBoat) {
void change(Shore* left, Shore* right, int ex, int can) {
if (((ex!=left->lastMove[0]) || (can!=left->lastMove[1])) && (left->hasBoat)) {