//do not use if,:? and other inference statements. Find the largest of the two numbers.
#include <iostream> using namespace STD ; int Main () {int a =- Ten ; int b =-100 ; int C = (A + B + abs (A-B)/2 ; //abs (x) is a function of absolute value, a+b+ (the difference between A and b) is twice times the maximum number, divided by 2 is the maximum number. cout << c << Endl; return 0 ;}
#include <iostream>using namespace STD;intMain () {intA =Ten;intb = -;intc = A-B;// intSr[] = {A, b};inti =unsigned(c) >> (sizeof(int)*8-1);//infer that the highest bit of C is 0 or 1,0 C is a positive number and 1 C is a negative number. This allows the size to be obtained. //unsigned type of number, left to move, no matter how left to fill 0. cout<< Sr[i] << Endl;//Check out the maximum value according to the subscript. return 0;}
C + + to find the maximum value of two numbers