Home > Back-end >  Novice to solve
Novice to solve

Time:09-25

Why the if ((a % 4==0 & amp; & A % 100!=0) | | a % 400==0) and the if (a % 4==0 & amp; & A % 100 | | a % 400==0) equivalent

CodePudding user response:

Consider a % 100 two things 1) 0 2) of 0
The first (1), namely a % 100 is 0, the above two conditional expression can be turned into a % 400==0
The first (2), namely a % 100 is 0, the above two expressions can be turned into a % 4==0 | | a % 400==0
So that the two conditional expressions are equivalent

CodePudding user response:

Is not equivalent, the second a lack of a pair of parentheses, the brackets are also important
A % 100!=0 and a % 100 is equivalent to the reason is: 0 is false, non-zero is true,
  • Related