Why is this answer to the logical thingie expression correct?

In my Prepared Comp Sci tutorial, I came across this question:

Assuming that x, y and z are integer variables, then of the following three logical expressions are equivalent to each other, that is, they have equal values ​​for all possible values ​​of x, y and z?

(x == y && x != z) || (x != y && x == z)
(x == y || x == z) && (x != y || x != z)
(x == y) != (x == z)

A. None of the three
B. I and II only
C. II and III only
D. I and III only
E. I, II, and III

I chose "B", but I was mistaken. I really think I need help understanding logic. The correct answer says something else, but I do not understand the logic. Here is the correct answer:

Expression III is the key to the answer: all three expressions indicate that exactly one of the two equalities, x == y or x == z, is true.

The expression I indicate that either the first, not the second, or the second, and not the first. Expression II states that one of the two is true, and one of them is false.
Expression III simply states that they have different meanings.

All three come down to the same thing. Answer: E.
+4
source share
2 answers
(x == y && x != z) || (x != y && x == z)

(x == y || x == z) && (x != y || x != z)

(x == y) != (x == z)

Let them break.

(x == y && x != z) || (x != y && x == z)
x is equal to y and not z, or x is equal to z and not y

So basically x is equal to one of [y|z], but y != z.

(x == y || x == z) && (x != y || x != z)
x is equal to y or x is equal to z, and x is not equal to y or x is not equal to z

This is a little trickier. This largely reduces to x equals one of [y|z] but not the other, or x is equal to y and not z, or x is equal to z and not y, in the same way as to the first equation.

, (x == y) , x != y . , true, x z. , x == z, x!= Y, . , , x is equal to one of [y|z] but not the other.

(x == y) != (x == z)
The value of the expression x == y is the opposite of the value of the expression x == z.

, . x y, , x z. , x y, x z. x is equal to one of [y|z] but not the other.

+4

, .

, true, , , , true.

, / " . " " :

: , .

Inclusive. .

, , . , , - , - , . , , .

OR = inclusive , XOR = exclusive .


(x == y && x != z) || (x != y && x == z)

(x y, z) OR (x y, z)

true , x . x == y x == z, .


(x == y || x == z) && (x != y || x != z)

(x y OR x z) AND (x y OR x z)

true, x . true, x . , true, .

, : x , x .


(x == y) != (x == z)

.

(x y) (x z).

: (x y) XOR (x z)

: x y x z.

, or :

, .

'', .

+3

Source: https://habr.com/ru/post/1536295/


All Articles