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

📄 6_6.txt

📁 耿国华高教出版社的《数据结构》的光盘(C语言)
💻 TXT
字号:
/* LeafCount保存叶子结点的数目的全局变量,调用之前初始化值为0 */
void leaf_a(BiTree root)
{
	if(root!=NULL)
	{
		leaf_a(root->LChild);
		leaf_a(root->RChild);
		if (root ->LChild==NULL && root ->RChild==NULL)
			LeafCount++;
	}
}

int leaf_b(BiTree root)
{
	int LeafCount2;
	if(root==NULL)	
		LeafCount2 =0;
	else 
		if((root->LChild==NULL)&&(root->RChild==NULL))
			LeafCount2 =1;
		else 
			LeafCount2 =leaf_b(root->LChild)+leaf_b(root->RChild);
	/* 叶子数为左右子树的叶子数目之和 */
	return LeafCount2;
}

⌨️ 快捷键说明

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