#include<iostream>
int func(int, int);
#define func(x,y) x/y+x
int main()
{
int i, j;
scanf("%d", &i);
scanf("%d", &j);
printf("%d ", func(i + j, 3));
printf("%d\n", func(i + j, 3));
}
int func(int x, int y) {
return y / x + y;
}
Run Code Online (Sandbox Code Playgroud)
应该添加到这个代码中,以便第一个输出是宏的结果,第二个输出是函数的结果?
Jar*_*d42 11
几种方式:
printf("%d ", func(i + j, 3)); // Macro call
#undef func // Macro is no longer defined
printf("%d\n", func(i + j, 3)); // Function call
Run Code Online (Sandbox Code Playgroud)
要么
printf("%d ", func(i + j, 3)); // Macro call
printf("%d\n", (func)(i + j, 3)); // Function call
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
681 次 |
| 最近记录: |