#在C中定义:发生了什么 [英] #define in C: what is happening
本文介绍了#在C中定义:发生了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以解释每一步发生了什么吗? 我知道最终输出是140.5,但是我不确定为什么会这样.每行产生140.5的结果是什么?
Can someone explain what is happening at every step? I know the final output is 140.5, but I am unsure why that is. What is happening at each line that is resulting in 140.5?
#define PI 3.1
#define calcCircleArea(r) (PI * (r) * (r))
#define calcCylinderArea(r,h) (calcCircleArea(r) * h)
int main() {
double i = calcCylinderArea(3.0,5.0 + 1); printf("%g", i);
}
推荐答案
步骤0
calcCylinderArea(3.0,5.0+1)
步骤1
(calcCircleArea(3.0)*5.0+1)
请注意,它不是(5.0+1)
.
问题从这里开始.
notice that it is not (5.0+1)
.
Problem begins here.
((PI*(3.0)*(3.0))*5.0+1)
步骤3
((3.1*(3.0)*(3.0))*5.0+1)
这篇关于#在C中定义:发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文