二叉树交换左右子树算法(递归)

void change(bitnode *&t)
{
	bitnode *temp = new bitnode;
	if (t)
	{
		if (t==NULL)return//若是根节点为NULL,递归结束
		temp = t->lchild;
		t->lchild = t->rchild;
		t->rchild = temp;
		change(t->lchild, x, y);
		change(t->rchild, x, y);
	}
}

猜你喜欢

转载自blog.csdn.net/qq_41938259/article/details/86222510