简体   繁体   中英

What is the difference between these two statements

I want to know what is the difference between these two statements in C. Are they same? Any logical proof whether they are same or not.

if (!(b[i]&&c[i+1]&&c[i+2]&&d[i+3]))

and:

if (((b[i] == 0|| c[i+1] == 0)|| c[i+2] == 0)|| d[i+3] == 0)

Yes, they will both evaluate to the same result.

If either of those values is 0 than the expression will return true and enter the if-statement(barring the missing parens at the end)

as far as proofs go, that is more or less DeMorgan's law

http://www.seas.upenn.edu/~ese570/Boolean_Identities.pdf

They are the same! For some proof you can read about De Morgan's laws

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM