计算机二级C语言中宏替换的替换规则是怎样的?麻烦举例说明。

如题。

#include<iostream>
using namespace std;
#define PI 3.141593 //宏定义PI,在下面程序中出现的PI都将用3.141593代替
#define S(a,b) a*b //宏定义S(a,b),a,b为形参,在下面程序中出现的S(a,b)都将用a*b代替
int main()
{
printf("%f\n",PI);
int a=S(3,4);
printf("%d\n",a);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-24
简单的宏替换#define f(x) x+5f(8)*f(10)就是8+5*10+5,而不是(8+5)*(10+5)
第2个回答  2013-09-24
来嘛去呀你不信就快就给
相似回答