[C]parameterized macros 带参数的宏
/* 请写成下列宏定义 1.min(a,b) 求a,b的最小值 2.islower(c), 判断c是否为小写字母 3.isleap(year), 判断year是否为闰年 4.circumference(r), 计算半径为r的圆周长 */ #include <stdio.h> #define min(a,b) ((a)>(b)?(a):(b)) #define isLower(c) (((c) < 'z' && (c) > 'a')? "True": "False") #define isLeap(year) (((((year)%4==0&&(year)%100!=0)||(year)%400==0)? "True": "False")) #define PI 3.14159265 #define circumference(r) (2*PI*(r)) int main() { printf("%s\n", isLeap(2004)); printf("%s\n", isLeap(100)); printf("%f\n", circumference(4)); printf("%c\n", min('z', 'A')); printf("%d\n", min(100, 67)); printf("%s\n", isLower('A')); return 0; }