#include"head.h"
BiThrTree B,Th;
int display()
{
system("color 0b");
string a; // 这样写程序可以防止 用户输入的不是1到7的数字 而是字符串 按照这样写即便是输入的字符串程序也不会出问题
cout<<"\n\t\t********************************************\n"
<<"\t\t* *\n"
<<"\t\t* 线索二叉树 *\n"
<<"\t\t* *\n"
<<"\t\t* *\n"
<<"\t\t* 1.先序创建二叉树 *\n"
<<"\t\t* *\n"
<<"\t\t* 2.建立中序线索二叉树,输出中序遍历 *\n"
<<"\t\t* *\n"
<<"\t\t* 3.查找已知结点中序的前驱和后继 *\n"
<<"\t\t* *\n"
<<"\t\t* 4.退出系统 *\n"
<<"\t\t* *\n"
<<"\t\t********************************************\n\n\t\t ※请输入数字选择使用功能 ";
cout<<"\t\t*****************************△特别提醒:输入功能后,您看到了主菜单 请注意向上拉动滚动条 ";
cin>>a;
if (a=="1")return 1;
if (a=="2")return 2;
if (a=="3")return 3;
if (a=="4")return 4;
return -1;//这样写可以防止用户不是输入1234567,当用户输入其他字符串时就返回主菜单
}
void main()
{
bool flag=true;
while (flag==true)
{
int a=display();
switch (a)
{
case 1:
{
system("cls");
CreateTree(B);InOrderThreading(Th,B);
cout<<"二叉树已建好!"<<endl;
}flag=true;break;
case 2:
{
system("cls");
cout<<" O(∩_∩)O~中序遍历结果为:";
InorderTraverse_Thr(Th);
cout<<endl;
}flag=true;break;
case 3:
{
system("cls");
char ch;
cout<<"请输入元素:";
cin>>ch;
Search_Node(B,Th,ch);
}flag=true;break;
case 4:flag=false;break;
default:system("cls");flag=true;
}
}
system("cls");
cout<<"\n\n\n\n\n";
cout<<"\t\t*******************************************\n\n"
<<"\t\t 谢谢使用 \n\n\n"
<<"\t\t ~O(∩_∩)O~ \n\n\n"
<<"\t\t*******************************************\n\n";
}