Chỉ dùng các toán tử “+ , - , * , /” mà không dùng các toán tử so sánh để tìm ra số lớn nhất giữa 2 số nguyên a , b ?.
Chỉ dùng các toán tử cộng trừ nhân chia mà không dùng các toán tử so sánh để tìm ra số lớn nhất giữa 2 số nguyên
Bạn muốn hỏi gì? Ý tưởng hay nhờ code hộ?
Mathematics is the shortest way to solve a problem and get a satisfactory result. If you only try to use the 4 basic calculations to solve a mathematical equation, you have not only lengthened the path but also created more problems for yourself
What do you study? In Computer Science, in the US and Europe, we have learned the subject of “Problem Oriented Programming Language” – or in simple terms, Compiler Technology. Remember that computers can only perform the following operations:
- Addition
- Shifts and
- Inversion.
The other calculations like Sub, Mul, Div and Comparisons have to be implemented based on the mentioned operations.
If you know how to multiply or divide 2 binary numbers of 32 bits, you can solve your own question with ease.
(|a - b| + (a + b)) / 2
giải thik
if a > b -> |a - b| = a - b + a + b = 2a / 2 = a
if b < a -> |a - b| = b - a + a + b = 2b / 2 = b