用宏定义求差的绝对值为什么不对啊?
查看原帖
用宏定义求差的绝对值为什么不对啊?
251011
Tokubara楼主2022/6/23 17:37
#define abs(x) ((x)>=0?(x):(-x))
printf("%lld\n%lld", max(sum_positive,sum_negative), abs(sum_positive-sum_negative)+1);

这样就有好几个点是 WA. 但如果改成:

printf("%lld\n%lld", max(sum_positive,sum_negative), (sum_positive>=sum_negative)?(sum_positive-sum_negative+1ll):(sum_negative-sum_positive+1ll));

就没有 WA. 这是咋回事呢?

2022/6/23 17:37
加载中...