1 #include <iostream>
2 using namespace std;
3
4 #define STR(s) #s // #的用法,转化为字符串
5 #define CONCAT(s1, s2) s1##s2 // ##连接后,作为变量名
6
7 #define MAX(a, b)\
8 {if((a)>(b))\
9 return (a);\
10 else\
11 return (b);\
12 }
13
14 #define swap(x, y)\
15 x = x + y;\
16 y = x - y;\
17 x = x - y;
18
19 #define Swap(x, y)\
20 int t = x;\
21 x = y;\
22 y = t;
23
24 #define max(a, b) (if (a < b) a; else b;)
25
26 int main()
27 {
28 cout << STR(test) << endl;
29 int ab = 10;
30 cout << CONCAT(a, b) << endl;
31 cout << STR(CONCAT(a, b)) << endl;
32
33 // cout << MAX(10, 3) << endl;
34 int a = 10, b = 11;
35 Swap(a, b);
36 cout << max(a, b) << endl;
37 return 0;
38 }
posted on 2011-10-08 12:59  吃吃户  阅读(322)  评论(0编辑  收藏  举报