1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int smallest( int a, int b ) { return a < b ? a : b ; }
int smallest( int a, int b, int c ) { return smallest( smallest(a,b), c ) ; }
int smallest( int a, int b, int c, int d ) { return smallest( smallest(a,b), smallest(c,d) ) ; }
int second_smallest( int a, int b, int c, int d )
{
const int min_value = smallest(a,b,c,d) ;
if( min_value == a ) return smallest(b,c,d) ;
else if( min_value == b ) return smallest(a,c,d) ;
else if( min_value == c ) return smallest(a,b,d) ;
else return smallest(a,b,c) ;
}
|