平成19年春期試験問題 午前問9

問9解説へ
論理型の変数A,Bの値に対して,次の条件文と同値なものはどれか。ここで,ANDは論理積,ORは論理和,XORは排他的論理和,Trueは真,Falseは偽,=は等号を表す。
if (A=True AND B=False) OR (A=False AND B=True) then …
if (A=True AND B=False) OR (A=False AND B=True) then …
- if ((A AND B) = True) then …
- if ((A AND B) = False) then …
- if ((A OR B) = True) then …
- if ((A XOR B) = True) then …
広告
解説
設問の条件文を論理式で書き換えると、
(A AND B) OR (A AND B)
となります。次にこの論理式をベン図で表現すると次のようになります。
上図をみるとAとBの排他的論理和(XOR)と同じであることがわかります。したがって同値な条件文は「(A XOR B) = True」になります。
(A AND B) OR (A AND B)
となります。次にこの論理式をベン図で表現すると次のようになります。

広告