1 #include<stdio.h>
2
3  #define MAX(A,B) A>B?2*A:2*B
4
5  void main()
6 {
7 int a=1,b=2,c=3,d=4,t;
8 t=MAX(a+b,c+d);
9 printf("%d\n",t);
10 }

 

 

 

这个程序的运行结果是10而不是14

原因:

宏是字符串替换

t = MAX(a+b,c+d) = a+b>c+d ? 2*a+b : 2*c+d = 2*3+4 = 10

相关文章:

  • 2021-09-10
  • 2021-12-10
  • 2021-06-09
  • 2021-09-02
  • 2021-11-29
猜你喜欢
  • 2021-10-23
  • 2021-05-20
  • 2022-01-28
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案