Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by Eugene ( 12 years ago )
template <int n> struct Int {
static const int N = n;
};
template <typename L, typename R, typename V> struct Tree {
typedef L Left;
typedef R Right;
typedef V Val;
};
struct TreeNIL {
typedef TreeNIL Left;
typedef TreeNIL Right;
typedef TreeNIL Val;
};
typedef Tree<TreeNIL, Tree<TreeNIL, Tree<TreeNIL, Tree<TreeNIL, Tree<TreeNIL, TreeNIL, Int<4> >, Int<3> >, Int<2> >, Int<1> >, Int<0> > MyTree;
template <typename TREE> struct Height {
typedef typename TREE::Left L;
typedef typename TREE::Right R;
static const int result = 1 + (Height<L>::result > Height<R>::result ? Height<L>::result : Height<R>::result);
};
template <> struct Height<TreeNIL> {
static const int result = 0;
};
int main(void) {
std::cout << Height<MyTree>::result << std::endl;
return 0;
}
Revise this Paste
Children: 70809