#include
#define A(a,b) (a>b)?a:b
int main()
{
printf("%d",A(8,2)*5);//结果为8
return 0;
}
/*
#include
#define A(a,b) ((a>b)?a:b)
int main()
{
printf("%d",A(8,2)*5);//结果为40
return 0;
}*/
#include
#define A(a,b) (a>b)?a:b
int main()
{
printf("%d",A(8,2)*5);//结果为8
return 0;
}
/*
#include
#define A(a,b) ((a>b)?a:b)
int main()
{
printf("%d",A(8,2)*5);//结果为40
return 0;
}*/
【若有帮助,采纳一下谢谢】
举个例子
#define add(a,b) a+b
int main(){
printf("%d\n",add(1,2)); //3
printf("%d\n",add(1,2)*2); //5
}
其实add(1,2)是替换成了1+2
第一句替换为1+2所以为3
第二句替换为1+2*2而不是(1+2)*2所以为5
使用define定义时只会直接替换而不会加括号之类的
所以你的第一句变成了 8>2?8:2*5
第二句变为(8>2?8:2)*5