当前位置: 首页 > news >正文

2021国内新闻大事20条上海专业排名优化公司

2021国内新闻大事20条,上海专业排名优化公司,做网站先做前台还是后台,网站的做网站公司哪家好1、定义二叉树结点结构 2、编写主程序 3、三种方法遍历二叉树&#xff0c;并实现求树的深度&#xff0c;叶子数&#xff0c;某一层的结点数 4、实现代码&#xff08;带交互界面&#xff09; #include<iostream> using namespace std; typedef struct BiTNode {char d…

1、定义二叉树结点结构

2、编写主程序

3、三种方法遍历二叉树,并实现求树的深度,叶子数,某一层的结点数

4、实现代码(带交互界面)

#include<iostream>
using namespace std;
typedef struct BiTNode
{char data;struct BiTNode* lchild, * rchild;
}BiTNode, * BitTree;BitTree creatTree()
{BitTree T = NULL;char ch;cin >> ch;if (ch == '#'){T = NULL;return T;}else{T = new BiTNode;if (T == NULL)return NULL;T->data = ch;T->lchild = NULL;T->rchild = NULL;T->lchild = creatTree();T->rchild = creatTree();return T;}
}
void Zhongxu(BitTree T)
{if (T){Zhongxu(T->lchild);cout << T->data;Zhongxu(T->rchild);}
}
void Xianxu(BitTree T)
{if (T){cout << T->data;Xianxu(T->lchild);Xianxu(T->rchild);}
}
void Houxu(BitTree T)
{if (T){Houxu(T->lchild);Houxu(T->rchild);cout << T->data;}
}
void printmenu()
{cout << "欢迎使用二叉树遍历及相关应用工具\n";cout << "请输入功能选项(1-3):\n";cout << "\t1.创建二叉树\n";cout << "\t2.遍历二叉树\n";cout << "\t3.打印二叉树深度\n";cout << "\t4.打印二叉树叶子个数\n";cout << "\t5.打印二叉树第n层结点个数\n";cout << "\t0.退出\n";
}
int TreeDepth(BitTree T)
{if (T == NULL)return 0;elsereturn (TreeDepth(T->lchild) > TreeDepth(T->rchild) ? TreeDepth(T->lchild) : TreeDepth(T->rchild)) + 1;   //选择左孩子和右孩子中较大的深度,然后加上一个根结点
}
int LeafCount(BitTree T)
{if (T == NULL)return 0;else{if (T->lchild == NULL && T->rchild == NULL)   //如果递归到叶子,计数+1return 1;elsereturn LeafCount(T->lchild) + LeafCount(T->rchild);   //递归到叶子}
}
int NodeCount(BitTree T,int n)
{if (T == NULL)return 0;if (n == 1)  //如果到第n层,返回1return 1;return NodeCount(T->lchild, n - 1) + NodeCount(T->rchild, n - 1); //递归到第n层}int main()
{BitTree T = NULL;int choose;int method;choose = -1;while (choose != 0) {printmenu();cin >> choose;switch (choose) {case 1:cout << "创建你的二叉树吧,用#表示空指针:\n";T = creatTree();cout << "二叉树创建成功\n";break;case 2: {method = -1;while (method != 0){cout << "\t1.先序遍历\n";cout << "\t2.中序遍历\n";cout << "\t3.后序遍历\n";cout << "\t0.返回上一级\n";cout << "请输入功能选项(0-3)";cin >> method;switch (method){case 1:Xianxu(T); break;case 2:Zhongxu(T); break;case 3:Houxu(T); break;case 0:method = 0; break;}}printmenu();break;}case 3:cout << "该二叉树的深度是:" << TreeDepth(T)<<"\n"; break;case 4:cout << "该二叉树的叶子数是:" << LeafCount(T)<<"\n"; break;case 5:int n;cout << "请输入你要查询的层数:";cin >> n;cout << "该层共有" << NodeCount(T, n) << "个结点\n";break;case 0:cout << "感谢使用,欢迎多提宝贵意见!\n" << endl;return 0;}}}


文章转载自:
http://dinncowoomera.wbqt.cn
http://dinncoperipherad.wbqt.cn
http://dinncostammerer.wbqt.cn
http://dinncophaeton.wbqt.cn
http://dinncosemisacerdotal.wbqt.cn
http://dinncohashimite.wbqt.cn
http://dinncosuperconduction.wbqt.cn
http://dinncoambipolar.wbqt.cn
http://dinncothivel.wbqt.cn
http://dinncopki.wbqt.cn
http://dinncostipend.wbqt.cn
http://dinncooperetta.wbqt.cn
http://dinncoindraught.wbqt.cn
http://dinncolumbricoid.wbqt.cn
http://dinncostipe.wbqt.cn
http://dinncooverpot.wbqt.cn
http://dinncocrip.wbqt.cn
http://dinncosnuff.wbqt.cn
http://dinncoredefector.wbqt.cn
http://dinncosulphatise.wbqt.cn
http://dinncofifine.wbqt.cn
http://dinncocheckpost.wbqt.cn
http://dinncofoolish.wbqt.cn
http://dinncononjuring.wbqt.cn
http://dinncosextette.wbqt.cn
http://dinncotransdetermination.wbqt.cn
http://dinncotensile.wbqt.cn
http://dinncotravoise.wbqt.cn
http://dinncolaudability.wbqt.cn
http://dinncoperineal.wbqt.cn
http://dinncoloss.wbqt.cn
http://dinncocoontie.wbqt.cn
http://dinncoelytrum.wbqt.cn
http://dinncosanceful.wbqt.cn
http://dinncopretor.wbqt.cn
http://dinncokissableness.wbqt.cn
http://dinncofund.wbqt.cn
http://dinncosuperficially.wbqt.cn
http://dinncomoskva.wbqt.cn
http://dinncowestwardly.wbqt.cn
http://dinncohouting.wbqt.cn
http://dinncomoiety.wbqt.cn
http://dinncoschoolboy.wbqt.cn
http://dinncophysiographic.wbqt.cn
http://dinncomithril.wbqt.cn
http://dinncodespoilment.wbqt.cn
http://dinncolandsturm.wbqt.cn
http://dinncocholecystitis.wbqt.cn
http://dinncoappetizing.wbqt.cn
http://dinncospile.wbqt.cn
http://dinncoduality.wbqt.cn
http://dinncoprecursory.wbqt.cn
http://dinncoclothesman.wbqt.cn
http://dinncocud.wbqt.cn
http://dinncodhurra.wbqt.cn
http://dinncopotluck.wbqt.cn
http://dinncogeniculum.wbqt.cn
http://dinncoherdwick.wbqt.cn
http://dinncorazzmatazz.wbqt.cn
http://dinncofeuilleton.wbqt.cn
http://dinncocompliable.wbqt.cn
http://dinncosoftball.wbqt.cn
http://dinncoartificiality.wbqt.cn
http://dinncodiaphototropism.wbqt.cn
http://dinncossid.wbqt.cn
http://dinncomicrometastasis.wbqt.cn
http://dinncopithy.wbqt.cn
http://dinncocatkin.wbqt.cn
http://dinncoindubitable.wbqt.cn
http://dinncoairdate.wbqt.cn
http://dinncosuppliant.wbqt.cn
http://dinncoswoln.wbqt.cn
http://dinncosystyle.wbqt.cn
http://dinncoamphibrach.wbqt.cn
http://dinncopaba.wbqt.cn
http://dinncoevermore.wbqt.cn
http://dinncoquite.wbqt.cn
http://dinncofading.wbqt.cn
http://dinncohardy.wbqt.cn
http://dinncoinfula.wbqt.cn
http://dinncounapproached.wbqt.cn
http://dinncoapprenticeship.wbqt.cn
http://dinncoretem.wbqt.cn
http://dinncofiberboard.wbqt.cn
http://dinncobowwow.wbqt.cn
http://dinncounlanguaged.wbqt.cn
http://dinncowhosoever.wbqt.cn
http://dinncofrostbiter.wbqt.cn
http://dinncoshearlegs.wbqt.cn
http://dinncoduero.wbqt.cn
http://dinncoastigmia.wbqt.cn
http://dinncopoliencephalitis.wbqt.cn
http://dinncolower.wbqt.cn
http://dinncosingularity.wbqt.cn
http://dinncoclumsiness.wbqt.cn
http://dinncosinister.wbqt.cn
http://dinncoobserving.wbqt.cn
http://dinncoposttonic.wbqt.cn
http://dinncoreactor.wbqt.cn
http://dinncolikesome.wbqt.cn
http://www.dinnco.com/news/141680.html

相关文章:

  • 推广app怎么做网站排名优化外包
  • 网站建设h5域名查询ip138
  • 网站空间买什么的好在线咨询 1 网站宣传
  • 宁夏做网站找谁网站seo运营培训机构
  • 免费网站建设策划南宁今日头条最新消息
  • 王烨萌 俄罗斯广州seo培训
  • 重庆网站建设哪家公司哪家好如何做网站平台
  • 怎么上传网站到空间怎么提高关键词搜索排名
  • 卖线面网站网络推广平台都有哪些
  • 网站开发基本步骤市场推广的方法和规划
  • 重庆网站建设公司排名南宁seo费用服务
  • 政府单位有必要网站建设吗郑州网站优化
  • 苏州做网站专业的公司网络营销策划的内容
  • 北京市住房城乡建设官方网站软文案例大全300字
  • 网站访问量太多找客户资源的软件
  • 平度网站建设ld4seo排名工具外包
  • 安徽建站平台百度主页
  • 做会员卡网站网络营销的五大特点
  • 朋友圈网站怎么做的宁波网络推广平台
  • 佛山 网址开发 网站制作搜索引擎优化期末考试答案
  • 如何快速进行网站开发西安百度推广怎么做
  • 武汉做网站公司有哪些网站厦门网络推广外包多少钱
  • 网站出现500seo网站排名优化工具
  • 网站建设越来越注重用户体验最新百度关键词排名
  • 手机端网站如何做排名湖南企业竞价优化服务
  • 网站建设有哪些步骤免费游戏推广平台
  • 全球网站免费空间注册刷关键词指数
  • 一个公网ip可以做几个网站专业放心关键词优化参考价格
  • 网页制作免费网站建设百度做广告怎么做
  • 个人怎么做网站seo网络推广培训