Max Min Middle

/*三者中的中间数*/
#define
Max(a,b) (a>b?a:b) #define Min(a,b) (a<b?a:b) int MiddleOfThree(int a, int b, int c) { int t1, t2, t3; t1 = Max(a, b); t2 = Max(a, c); t3 = Max(b, c); cout << "中间的数为 : " << endl; return Min(t1, Min(t2, t3))
}

/*两者中的较大数*/
int MaxOfTwo(int a, int b) { cout << "较大数为: "; return (a + b + abs(a - b)) >> 1; }

/*两者中的较小数*/
int MinOfTwo(int a, int b)
{ cout
<< "较小数为:"; return (a + b - abs(a - b)) >> 1; }

 

posted @ 2016-07-01 20:50  _in_the_way  阅读(206)  评论(0编辑  收藏  举报