📄 main.cpp
字号:
#include "bst.h"
int main()
{
BST<int> bst1;
int a[8] = {23, 45, 12, 9, 123, 87, 22, 9};
for (int i = 0; i < 8; i++) {
bst1.insert(a[i]);
}
cout << bst1.max() << endl;
cout << bst1.min() << endl;
int b = 145;
if (bst1.find(b))
cout << "successful" << endl;
else
cout << "cannot find " << b << endl;
bst1.remove(b);
BSTNode<int> *root = bst1.getRoot();
if (root)
cout << root->getData() << endl;
BSTNode<int> *temp = bst1.leftChild(bst1.getRoot());
if (temp)
cout << temp->getData() << endl;
temp = bst1.parent(bst1.leftChild(bst1.leftChild(bst1.getRoot())));
if (temp)
cout << temp->getData() << endl;
bst1.inOrder();
cout << endl;
cout << bst1.size() << endl;
cout << endl << bst1.depth() << endl << endl;
BST<int> bst2 = bst1;
if (bst2 == bst1)
cout << "equal" << endl;
else
cout << "not equal" << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -