⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.cpp

📁 C++编写的二叉树程序
💻 CPP
字号:
#include "Tree1.h"
void property3(TreeNode1 *p,int &n0,int &n2)
{
	if(p!=NULL)
	{
	if(p->left==NULL && p->right==NULL)//leaf node
		n0++;
	if(p->left==NULL && p->right==NULL)//2 degree leaf node
		n2++;
	property3(p->left,n0,n2);
	property3(p->right,n0,n2);
	}
}

void main()
{
	char *str="ABCDEFGH";
	cout<<"The TreeL "<<str<<endl;
	Tree1 t1(str);
	t1.preorder();
	t1.inorder();
	t1.postorder();
	int n0=0,n2=0;
	property3(t1.root,n0,n2);
	cout<<"check the feature3 of the binary tree,  ";
	cout<<"n0="<<n0<<", n2="<<n2<<",  n0==n2+1 ? ";
	if(n0==n2+1)
		cout<<"correct"<<endl;
	else
		cout<<"false"<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -