dimanche 23 octobre 2016

If statement to choose Either x or y is even, and the other is odd

I'm kinda confused about which of the if statements I have should be the appropriate one I want to check if either x or y is even, and the other is odd. Which would be the better one? :

    if(x%2 == 0 || y%2 == 0)

    if(x%2 != 0 || y%2 != 0)

    if(!(x%2 == 0 || y%2 != 0) || !(x%2 != 0 || y%2 == 0))

    if(x%2 == 0 || y%2 != 0)

    if(x%2 != 0 || y%2 == 0)

Aucun commentaire:

Enregistrer un commentaire