1、声明函数,使用if条件句判断较大值
#include<stdio.h>
int Max(int x,int y){
if(x>y){
return x;
}else{
return y;
}
}
int main() {
int a = 10;
int b = 20;
int max = Max(a, b);
printf("max=%d\n", max1);
return 0;
}
2、使用宏的方式判断较大值
#include<stdio.h>
#define MAX(X,Y)(X>Y?X:Y)
int main() {
int a = 10;
int b = 20;
int max = MAX(a, b);
printf("max=%d\n", max2);
return 0;
}
输出结果:
标签:判断,return,int,max,较大,Max,printf,20 From: https://blog.51cto.com/u_14464765/7037915