首页 > 其他 > 详细

有两个变量a和b,不用“if”、“? :”、“switch”或其他判断语句,找出两个数中比较大的

时间:2014-09-03 11:20:16      阅读:265      评论:0      收藏:0      [点我收藏+]

1、问题

There are two int variables: a and b, don‘t use "if"、"? :"、"switch" or other judgement statement, find out the biggest one of the two numbers.

(有两个变量a和b,不用“if”、“? :”、“switch”或其他判断语句,找出两个数中比较大的)


2、算法

int max = ( (a+b) + abs(a-b) ) / 2 ;

有两个变量a和b,不用“if”、“? :”、“switch”或其他判断语句,找出两个数中比较大的

原文:http://blog.csdn.net/u011476173/article/details/39023997

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!