#if,#ifdef和#ifndef的综合应用
1 #include<stdio.h>2
3 #define MAX
4
5 #define MAXIMUM(x,y) x>y?x:y
6 #define MINIMUM(x,y) x<y?x:y
7
8 int main()
9 {
10 int a=10,b=20;
11
12 #ifdef MAX
13 printf("\40:The larger one is %d\n",MAXIMUM(a,b));
14 #else
15 printf("\40:The lower one is %d\n",MINIMUM(a,b));
16 #endif
17
18
19 #ifndef MIN
20 printf("\40:The lower is %d\n",MINIMUM(a,b));
21 #else
22 printf("\40:The larger one is %d\n",MAXIMUM(a,b));
23 #endif
24
25 #undef MAX
26 #ifdef MAX
27 printf("\40:The larger one is %d\n",MAXIMUM(a,b));
28 #else
29 printf("\40:The lower one is %d\n",MINIMUM(a,b));
30 #endif
31
32
33 #define MIN
34 #ifndef MIN
35 printf("\40:The lower one is %d\n",MINIMUM(a,b));
36 #else
37 printf("\40:The larger one is %d\n",MAXIMUM(a,b));
38 #endif
39 return 0;
40
41 }
摘自 zhengmian
补充:软件开发 , C语言 ,