Home > Back-end >  If else statements to increase the difference between a switch
If else statements to increase the difference between a switch

Time:09-27

Do everyone a great god, and I recently in OLED display program, in case of need to the color display whether need to add a switch to control the color,
That statement is like


After I add the switch j's statement is like this


Can this statement cannot be executed correctly,

I use the same format in the main wrote this a few words of statements under test, but such statements normal execution, the following



The same format, but the results are different, the great god, please help to look at, some directions, thank you!!

CodePudding user response:

Where is the same? You are no else second, three if statement will judge,

The
refer to the original poster wenroudelang8888 response:
everyone a great god, I recently doing OLED display program, in case of need to the color display whether need to add a switch to control the color,
That statement is like


After I add the switch j's statement is like this


Can this statement cannot be executed correctly,

I use the same format in the main wrote this a few words of statements under test, but such statements normal execution, the following



The same format, but the results are different, the great god, please help to look at, some directions, thank you!!

After you modify the if statement judgment conditions from one into two, prone to errors, such as when (dat& 0 x80) is false, also performs a Set operation,
Since be switch, should be the first to determine whether the switch j equals 0, then judge dat& If 0 x80 is zero,

CodePudding user response:

Else is you will not meet the above judgment, do the following: if you have 6 kinds of combination, your code is the if (1) the CLR, else (23456), the rest is holding the set, and then to an if (2) perform the CLR, else (13456) set, didn't you realize that you are repeated in your statement?

CodePudding user response:

Or bring out j judgment alone, no matter put outside or inside, or directly if the else, don't add a second, it is to satisfy the three are carried out to 1, the rest is not implemented
  • Related