宏替换#define f(x) x * xint main(){int i;i = f(4);i = f(4 + 4);i = f(4 + 4) / (2 + 2);cout
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/13 02:19:02
宏替换#definef(x)x*xintmain(){inti;i=f(4);i=f(4+4);i=f(4+4)/(2+2);cout宏替换#definef(x)x*xintmain(){
宏替换#define f(x) x * xint main(){int i;i = f(4);i = f(4 + 4);i = f(4 + 4) / (2 + 2);cout
宏替换#define f(x) x * x
int main()
{
int i;
i = f(4);
i = f(4 + 4);
i = f(4 + 4) / (2 + 2);
cout << i << endl;
return 0;
}
请问为什么在这段代码中i的值分别为24,21,21?
宏替换#define f(x) x * xint main(){int i;i = f(4);i = f(4 + 4);i = f(4 + 4) / (2 + 2);cout
写错了吧,应该是16 24 21才对
int main()
{
int i;
i = 4*4; // 16
i = 4 + 4*4 + 4; // 4+16+4=24
i = 4 + 4*4 + 4 / (2 + 2); // 4+16+4/4 = 4+16+1=21
cout << i << endl;
return 0;
}