标签:style sp bs size as return ca c it
方案一:
所有比较都不用
int min = (a + b - abs(a - b)) / 2;(a与b的和减去a与b的差就等于a与b中较小值的两倍,再除以2即可得到较小值)
int max = (a + b + abs(a - b)) / 2; 同上
方案二:
int max(int a, b)
{
switch((unsigned int)(a - b) >> sizeof(int) * 8 - 1)
{
case 0: return b;
case 1:return a;
}
}
标签:style sp bs size as return ca c it
原文地址:http://blog.csdn.net/lansexinchen/article/details/40382123