How to use the characteristics of and-or conditional judgment to realize ternary conditional judgment in C language
This article mainly introduces how to use the characteristics of and-or conditional judgment in C language to achieve ternary conditional judgment, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Using the characteristics of and-or condition judgment to realize ternary condition judgment
First of all, let's introduce the usage of and and or:
And in python evaluates the expression from left to right, and returns the last value if all values are true, and the first false value if there is a false.
Whether it is a list, tuple, or string, empty represents False, non-empty indicates True
> 'python' and [] and (2mem3) [] >' python' and [2mem3] and (3Jing 4) (3Jing 4)
Or also evaluates the expression from left to right. If there is a true, the first true value is returned, and if both false, the last value is returned.
> 'python' or [3pr 4] or ()' python' >'or [] or () ()
Then, we use the characteristics of and-or conditional judgment to realize ternary conditional judgment:
A _
C = (a > b and [a] or [b]) [0]
>