demorgans-law

DeMorgan's law and C++

天涯浪子 提交于 2019-12-01 10:55:25
问题 For each of the following write the equivalent C++ expressions, without any unary negation operators (!). (!= is still permitted) Use DeMorgan's law !( P && Q) = !P || !Q !( P || Q) = !P && !Q For !(x!=5 && x!=7) !(x<5 || x>=7) !( !(a>3 && b>4) && (c != 5)) My answers: (x>5 || x<5) || (x>7 || x<7) x>=5 && x < 7 (a>3 && b > 4) && (c!=5) Are these correct? If not, can you give me answers and explain why they are wrong? I am a beginner in C++ so take it easy. 回答1: Check this out: !(x!=5 && x!=7)

Python And Or statements acting ..weird

*爱你&永不变心* 提交于 2019-11-28 14:15:47
I have this simple line of code: i = " " if i != "" or i != " ": print("Something") This should be simple, if i is not empty "" OR it's not a space " " , but it is, print Something. Now, why I see Something printed if one of those 2 conditions is False ? De Morgan's laws , "not (A and B)" is the same as "(not A) or (not B)" also, "not (A or B)" is the same as "(not A) and (not B)". In your case, as per the first statement, you have effectively written if not (i == "" and i == " "): which is not possible to occur. So whatever may be the input, (i == "" and i == " ") will always return False and

How to understand De Morgan Laws Boolean Expression

我们两清 提交于 2019-11-28 02:03:23
I got screwed when trying to understand this expression. I've thought several times but I cant get the meaning. ! (p || q) is equivalent to !p && !q For this one, somehow I can comprehend a little bit. My understanding is " Not (p q) = not p and not q" which is understandable ! (p && q) is equivalent to !p || !q For the second, I'm totally got screwed. How come My understanding is " Not (p q) = Not p or Not q " . How come and and or can be equivalent each other? as for the rule in the truth table between && and || is different. That's how I comprehend each expression, perhaps I have the wrong

deMorgan rules explained

夙愿已清 提交于 2019-11-27 08:03:56
Could you please explain the deMorgan rules as simply as possible (e.g. to someone with only a secondary school mathematics background) ? We have two values: T and F . We can combine these values in three ways: NOT , AND , and OR . NOT is the simplest: NOT T = F NOT F = T We can write this as a truth table : when given.. | results in... ============================ T | F F | T For conciseness x | NOT x ========= T | F F | T Think of NOT as the complement , that is, it turns one value into the other. AND works on two values: x y | x AND y ============= T T | T T F | F F T | F F F | F AND is T

How to understand De Morgan Laws Boolean Expression

爷,独闯天下 提交于 2019-11-26 23:36:53
问题 I got screwed when trying to understand this expression. I've thought several times but I cant get the meaning. ! (p || q) is equivalent to !p && !q For this one, somehow I can comprehend a little bit. My understanding is " Not (p q) = not p and not q" which is understandable ! (p && q) is equivalent to !p || !q For the second, I'm totally got screwed. How come My understanding is " Not (p q) = Not p or Not q " . How come and and or can be equivalent each other? as for the rule in the truth

deMorgan rules explained

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:37:20
问题 Could you please explain the deMorgan rules as simply as possible (e.g. to someone with only a secondary school mathematics background) ? 回答1: We have two values: T and F . We can combine these values in three ways: NOT , AND , and OR . NOT is the simplest: NOT T = F NOT F = T We can write this as a truth table : when given.. | results in... ============================ T | F F | T For conciseness x | NOT x ========= T | F F | T Think of NOT as the complement , that is, it turns one value