本文主要是介绍有两个变量a和b,不用“if”、“? :”、“switch”或其他判断语句,找出两个数中比较大的,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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”或其他判断语句,找出两个数中比较大的的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!