#define max(a, b) ((a) > (b) ? (a) : (b))

#define min(a, b) ((a) < (b) ? (a) : (b))

// #define 을 이용해서 큰값과 작은 값을 간단하게 선택할 수 있다.

#include <assert.h>
 
template< typename T > inline T MIN_T( const T& a, const T& b) { return (a > b) ? (b) : (a)}
template< typename T > inline T MAX_T( const T& a, const T& b) { return (a < b) ? (b) : (a)}
template< typename T > inline T ABS_T( const T& a)             { return (a > 0) ? (a) : (-a); }
 
template< typename T > inline T BETWEEN_T( const T& value, const T& min, const T& max )
{ 
  if( min > max ) assert( !"min is bigger than max" );
  return MAX_T( min, MIN_T( max, value ) );
}
 
2006/05/13 18:14 2006/05/13 18:14

글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

덧글을 달아 주세요