路过的C大神来看看这道题.#include#define M(x,y,z) x*y+zint main(){int a=1,b=2,c=3;printf("%d\n",M(a+b,b+c,c+a));return 0;}这个程序运行的结果为什么是12.最好能把流程写一下

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 15:03:50
路过的C大神来看看这道题.#include#define M(x,y,z) x*y+zint main(){int a=1,b=2,c=3;printf(

路过的C大神来看看这道题.#include#define M(x,y,z) x*y+zint main(){int a=1,b=2,c=3;printf("%d\n",M(a+b,b+c,c+a));return 0;}这个程序运行的结果为什么是12.最好能把流程写一下
路过的C大神来看看这道题.
#include
#define M(x,y,z) x*y+z
int main()
{
int a=1,b=2,c=3;
printf("%d\n",M(a+b,b+c,c+a));
return 0;
}
这个程序运行的结果为什么是12.最好能把流程写一下

路过的C大神来看看这道题.#include#define M(x,y,z) x*y+zint main(){int a=1,b=2,c=3;printf("%d\n",M(a+b,b+c,c+a));return 0;}这个程序运行的结果为什么是12.最好能把流程写一下
宏替换后是
a + b * b + c + c + a

1 + 2 * 2 + 3 + 3 + 1 = 12

应该这样定义宏
#define M(x,y,z) (x)*(y)+(z),那么替换后是
(1 + 2) * (2 + 3) + (3 + 1) = 19