linkedbintree.cpp
来自「数据结构二叉树的功能实现, 比如在二叉搜索树上查找或者删除一个结点。」· C++ 代码 · 共 44 行
CPP
44 行
// LinkedBinTree.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "CBinTree.h"
#include "string.h"
int main(int argc, char* argv[])
{
BinTree<int> BT1(-1);
int i=0,j=0;
cout<<"InOrder print:"<<endl;
BT1.InOrder(BT1.GetTop());
cout<<endl;
cout<<"Level print:"<<endl;
BT1.LevelOrder(BT1.GetTop());
cout<<endl;
BT1.LeafSize(BT1.GetTop(),i);
cout<<"The leaf_node size:"<<i<<endl;
BT1.OffsetSize(BT1.GetTop(),j);
cout<<"The offset_node size:"<<j+1<<endl;
int h=BT1.Height(BT1.GetTop());
cout<<"The height of the tree is:"<<h<<endl;
cout<<"Input the node which you want to search:";
int k;
cin>>k;
if(BT1.Search(k,BT1.GetTop())==NULL) cout<<"The node searched doesn't exit!"<<endl;
else
cout<<"The searched node's address is:"<<BT1.Search(k,BT1.GetTop())<<endl;
cout<<"Input the node which you want to remove:";
cin>>k;
BinTreeNode<int> *p=BT1.GetTop();
bool w=BT1.Remove(k,p);
if(w==false) cout<<"The node should be removed doesn't exit!"<<endl;
else
{
cout<<"Print the removed tree in level:"<<endl;
BT1.LevelOrder(p);
cout<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?