求中位数的宏真的会被使用吗?
编写带参数的宏:MEDIAN(x,y,z)--计算x,y和z的中值(中位数)
我写的是这样:

#include <stdio.h> #include <stdlib.h> #include <string.h> #define MEDIAN(x,y,z) ((((x)>(y)&&(y)>(z))||((x)<(y)&&(y)<(z)))?y:((((y)>(x)&&(x)>(z))||((y)<(x)&&(x)<(z)))?x:z)) int main(){ printf("%d", MEDIAN(1,2,3)); return 0; }测试了几下,也没出错。可是这么长的宏写出来真的有实际意义吗?会在实际中用的到吗?看着那堆括号就晕了。