idk why these stuffs get stashed for so long and I didn't ever commit them

This commit is contained in:
2025-11-06 09:43:54 +08:00
parent 5dbdfef1a1
commit e01c041259
232 changed files with 22806 additions and 1256 deletions

View File

@@ -0,0 +1,76 @@
#include<iostream>//cout,cin
#include<string>
#include"InThrBiTree.h"
using namespace std;
void dispmenu()
{ // 显示主菜单
cout<<endl;
cout<<"1-创建二叉树\n";
cout<<"2-中序线索化二叉树\n";
cout<<"3-中序遍历中序线索二叉树\n";
cout<<"4-显示二叉树\n";
cout<<"0-退出\n";
}
// 测试数据
string fbt="a b d # # e # # c f # # g # #"; // 满二叉树最后一层每个叶结点后有两个#
string cbt="a b d # # e # # c # #"; // 完全二叉树每个叶结点后有两个#
string gbt="a b # d # # c e # # #"; // 一般二叉树
string obt="a b c d # # # # #"; // 左斜树
void main()
{
int level;
ThrBTNode<char> *bt;
system("cls"); // 清屏
int choice;
do
{
dispmenu(); // 显示主菜单
cout<<"Enter choice(1~7):";
cin>>choice;
switch(choice)
{
case 1: // 创建二叉树
cout<<"测试数据参考:"<<endl;
cout<<"满二叉树:"<<fbt<<endl;
cout<<"完全二叉树:"<<cbt<<endl;
cout<<"一般二叉树:"<<gbt<<endl;
cout<<"左斜二叉树:"<<obt<<endl;
cout<<"请按先序序列的顺序输入二叉树,#为空指针域标志:"<<endl;
CreateBiTree(bt);
level=1;
DispBiTree(bt,level);
break;
case 2: // 中序线索化二叉树
bt=CreateInThread(bt);
cout<<"中序线索化成功!";
cout<<endl;
break;
case 3: // 中序遍历中序线索二叉树
cout<<"中序遍历序列为:"<<endl;
cout<<endl;
InThrBiTree(bt);
break;
case 4: // 显示二叉树
cout<<"2-显示二叉树"<<endl;
level=1;
DispBiTree(bt,level);
cout<<endl;
break;
case 0: // 退出
cout<<"结束运行bye-bye!"<<endl;
DestroyThrBiTree(bt);
break;
default: // 无效选择
cout<<"无效选择!\n";
break;
}
}while(choice!=0);
return;
}