#include <iostream>
using namespace std;
#define AB(a,b) (((a-b)>>31)&0x1)
void minmax(int a,int b)
{
int max,min;
max=(abs(a-b)+a+b)/2;
min=((a+b)-abs(a-b))/2;
cout<<"max="<<max<<" min="<<min<<endl;
}
/*Use the highest bit of the result of (a-b) and (b-a) to indicate Positive or Negative*/
void minmax_(int a,int b)
{
int max,min;
max=a*AB(b,a)+b*AB(a,b);
min=a*AB(a,b)+b*AB(b,a);
cout<<"max="<<max<<" min="<<min<<endl;
}
int main(void)
{
int a=3;
int b=4;
minmax(a,b);
minmax_(a,b);
return 0;
}