// XK> example
[Question] If ,? :, Switch, and other judgment statements to find the maximum and minimum values of the two given Variables
[Answer] A + B may cause overflow.
The answer below is from 《ProgramThe second edition of the "Employee Interview Guide" obviously has overflow problems. However, this idea is a bit interesting.
Int max = (a + B + ABS (a-B)> 1; int min = (a + B-ABS (a-B)> 1;
This question is purely an odd sex technique and does not make much sense. The Solution Below is better, but a-B may also overflow during the negative number operation!
Int max = A-(a-B)> 31) & (a-B); int min = a + (B-a)> 31) & (B-));
// XK> example
Question: exchange the values stored in two instead of 3rd variables.
[Answer] This is a common tip in programming. The answer below is a good note. The Three ^ = operators are alternately filled with two variable names.
A ^ = B ^ = a ^ = B;