📄 avlmain.cpp
字号:
#include "AVL.h"
void command()
{
std::cout<<"说明:"<<endl;
std::cout<<" 本程序演示了平衡二叉树的插入和删除。"<<endl;
std::cout<<" 本程序模拟了DOS的命令行,各有效命令见下:"<<endl;
std::cout<<" clear/delall:清空树; show:显示树的中序遍历结果;"<<endl;
std::cout<<" add:插入一个结点; del:删除一个结点;"<<endl;
std::cout<<" quit/exit:退出程序;"<<endl;
std::string str;
bool exitif = false;
OperationAvl at;
while(!exitif)
{
std::cout<<">>";
std::cin>>str;
if(str == "exit")
exitif = true;
else if(str == "quit")
exitif = true;
else if((str == "clear")||(str == "delall"))
{
at.Avl_clear();
}
else if(str == "add")
{
std::cin>>str;
str+='\0';
if(at.Avl_in(str))
cout<<"插入成功^_^"<<endl;
else
cout<<"插入失败~_~"<<endl;
}
else if(str == "del")
{
std::cin>>str;
str+='\0';
if(at.Avl_out(str))
cout<<"删除成功^_^"<<endl;
else
cout<<"删除失败~_~"<<endl;
}
else if(str == "show")
{
at.Avl_show();
}
else
{
std::cout<<str<<"不是内部命令,请仔细阅读说明。"<<endl;
}
}
}
int main()
{
command();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -