📄 b_13_2.cpp
字号:
#include "stdafx.h"
#include <iostream>
#include<iomanip>
#include <string>
#include "tree.h"
using namespace std;
template <class Type>
void Tree <Type> :: leafCount(treeNode<Type> *&p,int& number)
{
if (p != NULL)
{
leafCount (p->Left(),number);
leafCount (p->Right(),number);
if (p->Left()==NULL && p->Right()==NULL)
number++;
}
}
char A[] = {'A','B','D','G','C','E','F'},B[] = {'D','G','B','A','E','C','F'};
void main()
{ Tree <char> a;
int number =0;
a.makeTree(0,6,0,6,a.root);
cout << "该树的先序序列是:"<<endl;
a.traversalPreOrder(a.root);
a.leafCount(a.root,number);
cout << endl;
cout << "该树的叶子的数量是:"<<number<<endl;
cin.get(); //等待结束,以便调测程序,可以删除
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -