求二叉树中结点值为x的个数

int xNum(BTNode* bt, char x)
{
	int lnum, rnum;

	if (bt == NULL)
		return 0;
	else
	{
		lnum = xNum(bt->lchild, x);
		rnum = xNum(bt->rchild, x);
		if (bt->data == x)
			return lnum + rnum + 1;
		else
			return lnum + rnum;
	}
}

 


版权声明:本文为qq_41549786原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。