fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. inline constexpr int func(int a, int b) {
  6. return a + ((b-a) & ((unsigned)(a>b) - 1));
  7. }
  8.  
  9.  
  10. int main() {
  11.  
  12. cout << func(5, 4);
  13.  
  14. cout << endl << func(rand()%10, rand()%10);
  15.  
  16. // your code goes here
  17. return 0;
  18. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
5
6