bst.cpp
来自「常用算法与数据结构原代码」· C++ 代码 · 共 43 行
CPP
43 行
// test binary search tree class
#include <iostream.h>
#include "bst.h"
BSTree<DataType,int> y;
void main(void)
{
DataType q;
for (int i=0;i<5;i++)
{ cin>>q;
y.Insert(q);
}
cout << "Elements in ascending order are" << endl;
y.Ascend();
DataType s;
try{
y.DeleteMax(s);
cout<<s<<endl;
y.Delete(4,s);
cout << "Delete of 4 succeeds " << endl;
cout <<s<< endl;
cout << "Elements in ascending order are" << endl;
y.Ascend();
y.Delete(8,s);
cout << "Delete of 8 succeeds " << endl;
cout << s << endl;
cout << "Elements in ascending order are" << endl;
y.Ascend();
y.Delete(6,s);
cout << "Delete of 6 succeeds " << endl;
cout << s<< endl;
cout << "Elements in ascending order are" << endl;
y.Ascend();
y.Delete(6,s);}
catch (...)
{cout << "Delete fails " << endl;}
cout << "Elements in ascending order are" << endl;
y.Ascend();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?