Dzwebs.Net

撰写电脑技术杂文十余年

C语言:#if #ifdef和#ifndef的综合应用

Admin | 2008-1-13 13:38:48 | 被阅次数 | 30811

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  C语言#if #ifdef和#ifndef的综合应用代码如下:

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


该杂文来自: 算法杂文

上一篇:C语言register和#define命令用法

下一篇:C语言#include的实例

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计