Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the characteristics of and-or conditional judgment to realize ternary conditional judgment in C language

Shulou Source: shulou.com Published: 2022-06-01 04:51:14 09月21日 Update

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]

>

Tags: Conditions features ternary articles languages expressions values interests at the same time characters strings more friends knowledge editing industry information information channels or channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Docker OPPO Reno MariaDB