int median( int a, int b, int c )
{
int min = a, max =a;
if( b < min )
min = b;
else
max = b;
if( c < min )
min = c;
else if( c > max )
max = c;
return a + b + c - min - max;
}
3次比较,6次赋值,4次加法
int median( int a, int b, int c )
{
int min = a, max =a;
if( b < min )
min = b;
else
max = b;
if( c < min )
min = c;
else if( c > max )
max = c;
return a + b + c - min - max;
}
3次比较,6次赋值,4次加法