C language how to compare the size of two numbers

method one

Comparative if statement, as follows

Second way

Conditions comparison operator, key line as
c = a> = b a: ? B;
Summary:
The only ternary operator (conditional operator) can be used to obtain two numbers that minimum number or maximum. More concise form.

Three ways

Function method can also get this problem, create a Max function, defined as follows
Here Insert Picture Description
and then add the main function main, function calls to Max declared
Here Insert Picture Description
three common methods to stop here friends.

Released five original articles · won praise 0 · Views 119

Guess you like

Origin blog.csdn.net/Noreturnperiod/article/details/104877961