当前位置:网站首页>C language: comprehensive application of if, def and ifndef

C language: comprehensive application of if, def and ifndef

2022-07-06 21:34:00 Nianchi ichthyology programming

#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 bigger number is :%d\n",MAXIMUM(a,b));
#else
	printf(" The smaller number is :%d\n",MINIMUM(a,b));
#endif
#ifdef MIN
	printf(" The smaller number is :%d\n",MINIMUM(a,b));
#else
	printf(" The bigger number is :%d\n",MAXIMUM(a,b));
#endif
#undef MAX
#ifdef MAX
	printf(" The bigger number is :%d\n",MAXIMUM(a,b));
#else
	printf(" The smaller number is :%d\n",MINIMUM(a,b));
#endif
#define MIN
#ifndef MIN
	printf(" The smaller number is :%d\n",MINIMUM(a,b));
#else
	printf(" The bigger number is :%d\n",MAXIMUM(a,b));
#endif
	return 0;
} 

Running results :

 The bigger number is :20
 The bigger number is :20
 The smaller number is :10
 The bigger number is :20
原网站

版权声明
本文为[Nianchi ichthyology programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061307031240.html