1 #include<stdio.h>
2
3 #define SWAP(T,x,y) {T t=x;x=y;y=t;}//宏函数
4 #define MAX(x,y) (x<y?y:x)
5 #define PI 3.14159
6 #define AREA(r) PI*(r)*(r) //宏函数传参要 加括号(r)
7 #define STR(x) puts(#x)
8
9 void welcomus(){STR(今天天气不错);}
10 void welcomyou(){printf("确实不错\n");}
11 #define wel(who) welcom##who() //调用函数加##
12 int main()
13 {
14 puts(__FILE__);
15 printf("%d\n",__LINE__);
16 puts(__DATE__);
2
3 #define SWAP(T,x,y) {T t=x;x=y;y=t;}//宏函数
4 #define MAX(x,y) (x<y?y:x)
5 #define PI 3.14159
6 #define AREA(r) PI*(r)*(r) //宏函数传参要 加括号(r)
7 #define STR(x) puts(#x)
8
9 void welcomus(){STR(今天天气不错);}
10 void welcomyou(){printf("确实不错\n");}
11 #define wel(who) welcom##who() //调用函数加##
12 int main()
13 {
14 puts(__FILE__);
15 printf("%d\n",__LINE__);
16 puts(__DATE__);
17 puts(__TIME__);//已经有定义的宏函数
18
19 int a = 10,b = 20;
20 double c = 12.3,d = 45.6;
21 int e = 50,f = 60;
22 SWAP(int,a,b)
23 SWAP(double,c,d)
24 printf("a = %d,b = %d,c = %g,d = %g\n",a,b,c,d);
25 printf("%d , %g",MAX(a,b),AREA(a+b));
26 STR(hello);
27 wel(us);
28 wel(you);
29
30 return 0;
31 }
/*
#include
#define
#ifdef
#ifndef
#else
#endif
#undef
*/