本文整理汇总了C++中Tree::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Tree::GetHeight方法的具体用法?C++ Tree::GetHeight怎么用?C++ Tree::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::GetHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Tree<int> tree;
tree.Add(987,12);
tree.Add(665,5);
tree.Add(714,3);
tree.Add(215,10);
tree.Add(890,7);
tree.Add(531,11);
tree.Add(920,6);
tree.Add(110,9);
cout << "Tree height : " << tree.GetHeight() << endl
<< "There are " << tree.GetNodesOnLevel(2) << " nodes on 3rd level." << endl;
cout << "Tree element with key " << 7 << " is: " << endl;
tree.PrintInfo(7);
_getch();
return 0;
}
示例2: main
int main()
{
Tree<int> *tree =
new Tree<int>(1,
new Tree<int>(2, NULL,
new Tree<int>(3,
new Tree<int>(5, NULL,
new Tree<int>(6,
new Tree<int>(8, NULL, new Tree<int>(9, NULL, new Tree<int>(10))) //8
) // 6
), // 5
new Tree<int>(4,
new Tree<int>(7)
) // 4
) // 3
) // 2
); // 1
cout << "Tree height: " << tree->GetHeight() << endl;
delete tree;
_getch();
return 0;
}