我有这个逻辑运算符表达式:
!(!(a != b) && (b > 7))
你如何简化它并找到等价物?
使用德摩根定律。
!(!(a != b) && (b > 7))
!!(a != b) || !(b > 7)
a != b || b <= 7
正如其他人提到的:德摩根定律
!(!(a != b) && (b > 7)) // x != y --> !(x == y)
!(!!(a == b) && (b > 7)) // !!x --> x
!((a == b) && (b > 7)) // !(x && y) --> !x || !y
!(a == b) || !(b > 7) // !(x == y) --> x != y;; !(x > y) --> x <= y
(a != b) || (b <= 7)