The following five methods are used to find out the larger number and the smaller number respectively. The smaller number of code is in the comment, but the test is not running.
int Find1 (int a, int b) {return ((A + B) + ABS (A-b))/2;
Return ((A + B)-ABS (A-b))/2;
}/* When a is greater than B, a-b is positive, right move sizeof (int) * 8-1, the rightmost one is 0,0^1 = 0; When a is less than B, a-b is negative, and the rightmost one is 1,1^1 = 1 */int Find21 (int a, int b) {
int c[2] = {A, b};
int z = a-b;
z = (z >> (sizeof (int) * 8-1)) & 1;
return c[z];
/* int c[2] = {b, a};
int z = a-b;
z = (z >> (sizeof (int) * 8-1)) & 1;
return c[z];
*/} int Find22 (int a, int b) {int flag = ((a-b) >> (sizeof (int) * 8-1)) & 1;
Return (A-(a-b) * flag);
Return (b-(b-a) * flag);
int Find3 (int a, int b) {int c[2] = {A, b};
Return C[a < b];
return c[a > B];
}/* This method is not able to handle a case with a negative number of two digits and a few 0 cases, but this is also listed here. A<b, a/b=0, so the divisor is b* (b/a), the divisor is b/a, the result is B a=b, a/b=1, so the divisor is a+b=2a, the divisor is 2, the result is a a>b, b/a=0, so the divisor is a A * (A/b), the divisor is a/b, the result is
A/int Find4 (int a, int b) {int larger = (A * (A/b) + b* (b/a))/(A/b + b/a); Long smaller = (b* (A/b) + A * (b/a))/(A/b + b/a);
return larger;
int main () {int A, B;
while (1) {cin >> a >> b;
cout << Find1 (A, b) << "";
cout << Find21 (A, b) << "";
cout << Find22 (A, b) << "";
cout << Find3 (A, b) << "";
cout << Find4 (A, b) << Endl; }
}