在C语言当中定义带参数的宏,用于求某数的平方
来源:百度知道 编辑:UC知道 时间:2024/07/02 10:59:48
定义带参数的宏,用于求某数的平方
怎么算?高手们 帮我编写一个程序啊!小第谢谢拉!!!
怎么算?高手们 帮我编写一个程序啊!小第谢谢拉!!!
比如你求16的平方:
#include<stdio.h>
#define NUM 16
#define RET(i) ((i)*(i))
int main(void)
{
printf("result is: %d\n",RET(NUM));
return 0;
}
#define RESULT(c) (c*c)
void main()
{
int a = 6;
int b;
b = RESULT(a);
printf("%d",b);
}
#include <stdio.h>
#define SQUARE(x) ((x) * (x))
int main()
{
//在里面调用
int i = SQUARE(2);
//i是4;
return 1;
}
ps.楼上的大哥粗心了,要放()啊。