samedi 21 mars 2020

Express a truth table using a single if-condition

My code looks like this:

/*
 * A B
 * 0 0 -> 1
 * 0 1 -> 0
 * 1 0 -> 0
 * 1 1 -> 0
 */

#define A condition_1
#define B condition_2

if (A) {
    // do nothing
} else {
    if (B) {
        // do nothing
    } else {
        // do something
    }
}

Above I've reported the truth table for two conditions where 1 is true and 0 is false, is there a way to express the truth table into a single if-condition?

Aucun commentaire:

Enregistrer un commentaire