topic:
Define a macro MAX with three parameters to find the maximum value among the three parameters
Idea analysis:
1. Mainly use a function to find the maximum value among three parameters.
You need to use (x) > (y)? Multiple nesting of (x) : (y)
2. Or set the intermediate value temp in the function Save the larger one and compare the two to get the maximum value.
Note that () must be added outside each element
Code:
#include<stdio.h>
#define Max(a, b, c) (a) > (b)? ((a) > (c)? (a) : (c)) : ((b) > (c)? (b):(c))
int main()
{
int a = 0, b = 0, c = 0, _max = 0;
printf("Input three number:");
scanf("%d%d%d",&a,&b,&c);
_max = Max(a, b, c);
printf("Output the max number:%d",_max);
return 0;
}