令人困惑的布尔表达式
给定布尔变量 x
、y
和 z
的这些值:
x = true
y = false
z = true
为什么以下逻辑表达式的计算结果为 true
?
(x || !y) && (!x || z)
Given these values for the boolean variables x
, y
, and z
:
x = true
y = false
z = true
Why does the following logical expression evaluate to true
?
(x || !y) && (!x || z)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
代入
x
、y
和z
的值:翻转否定值:
替换 ORed 语句(如果一侧为 true,则整个语句为真):
替换ANDed语句(如果两边都为真,则整个语句为真):
Substitute in the values of
x
,y
, andz
:Flip the negated values:
Replace the ORed statements (if one side is true, the whole statement is true):
Replace the ANDed statement (if both sides are true, the whole statement is true):
真或假永远是真。
真||错误
真实和真实永远是真实的。
真&&正确
True or False is always True.
true || false
True and True is always True.
true && true
X 在第一个分组中为真,导致第一个分组为真。 Z 在第二分组中为真,导致第二分组为真。因此组 1 和组 2 为真。
X is true in the first grouping causing the first grouping to be true. Z is true in the second grouping causing the second grouping to be true. Therefore group 1 and group 2 are true.
实际上,请告诉我们到底是什么令人困惑;我有点困惑你觉得它很令人困惑。
Actually, please tell us what's so confusing; I am slightly confused that you find it confusing at all.