- 1、本文档共36页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Main.cpp
#includeiostream
#includestring
#includeiomanip
#includeconio.h
#includeTree.cpp
using namespace std;
//-----------------------------------------------------------------------------
bool Convert1(string s1,string s2,string str);
bool Convert2(string s1,string s2,string str);
void menu();
void center(string str,bool e=1);
//-----------------------------------------------------------------------------
void main(){
menu();
char ch=getch();
while(!isdigit(ch)){
coutendl;
center(您的输入有误,请重新输入:,0);
ch=getch();
coutchendl;
}
Treechar t;
while(1){
switch(ch){
case 1:{
if(t.Getroot()!=NULL){
coutendl;
center(您要重新创建二叉树吗?);
center((请按回车键继续创建,其他键返回上一级。));
center(请选择(回车键/其它键):,0);
char ch=getch();
coutendl;
if(ch!=\r){
center(返回上一级成功!);
break;
}
t.Destory(t.Getroot());
coutendl;
}
coutendl;
coutstring(15, )string(20,*)创建二叉树string(20,*)endlendl;
coutstring(31, )1:广义表构造法endl;
coutstring(31, )2:先序和中序构造法endl;
coutstring(31, )3:中序和后序构造法endl;
coutstring(15, )string(50,*)endl;
center(请选择(0-3):,0);
char ch=getch();
coutchendl;
while(!(ch=0 ch=3)){
center(您的输入有误,请重新输入:,0);
ch=getch();
coutchendl;
}
switch(ch){
case 1:
{
coutstring(15, )请输入广义表字符串:;
for(string str;cinstr; )
{
t=str;
if(t.Getroot()==NULL)
{
coutstring(15, )您的输入有误,请重新输入:;
}
else
{
break;
}
}
center(广义表构造法创建二叉树成功!);
coutstring(15, )string(17,*)现在的二叉树:string(17,*)endl;
t.PrintTree(t.Getroot());
break;
}
case 2:
{
string str;
string s1,s2;
coutstring(15, )请输入先序遍历字符串:;
cins1;
coutstring(15, )请输入中序遍历字符串:;
cins2;
while(1)
{
if(Convert1(s1,s2,str))
{
break;
}
else
{
coutstring(15, )您的输入有误,请重新输入先序遍历字符串:;
cins1;
coutstring(15,
文档评论(0)