现在的位置: 首页 > 综合 > 正文

【程序49】#if #ifdef和#ifndef的综合应用

2013年05月11日 ⁄ 综合 ⁄ 共 576字 ⁄ 字号 评论关闭

【题目】:#if #ifdef和#ifndef的综合应用

#include<stdio.h>
#define MAX
#define MAXIMUM(x,y)(x>y)?x:y
#define MINIMUM(x,y) (x>y)?y:x
int main()
{
	int a=10,b=20;
    #ifdef MAX
	 printf("The larger one is %d\n",MAXIMUM(a,b));
    #else
	 printf("The lower one is %d\n",MINIMUM(a,b));
    #endif
    #ifndef MIN
	 printf("The lower one is %d\n",MINIMUM(a,b));
    #else
	 printf("The larger one is %d\n",MAXIMUM(a,b));
    #endif
    #undef MAX
    #ifdef MAX
	 printf("The larger one is %d\n",MAXIMUM(a,b));
    #else
	 printf("The lower one is %d\n",MINIMUM(a,b));
    #endif
    #define MIN
    #ifndef MIN
	 printf("The lower one is %d\n",MINIMUM(a,b));
    #else
	 printf("The larger one is %d\n",MAXIMUM(a,b));
    #endif
	return 0;
}

 

抱歉!评论已关闭.