标签:sub 使用 数字 题目 sam div public write else
请编写一个方法,找出两个数字中最大的那个。条件是不得使用if-else等比较和判断运算符。
给定两个int a和b,请返回较大的一个数。若两数相同则返回任意一个。
1,2
返回:2
class Max { public: int getMax(int a, int b) { // write code here return (a+b+abs(a-b))/2; } };
标签:sub 使用 数字 题目 sam div public write else
原文地址:http://www.cnblogs.com/xiuxiu55/p/6746701.html