输出二叉树中的所有叶子节点
关键:叶子节点的左右子树都为空
void PrintLeaves(BinTree BT) { if(BT) { if(!BT->Left && !BT->Right) //如果BT节点是叶子 printf("%d", BT->Data); PrintLeaves(BT->Left); PrintLeaves(BT->Right); } }
关键:叶子节点的左右子树都为空
void PrintLeaves(BinTree BT) { if(BT) { if(!BT->Left && !BT->Right) //如果BT节点是叶子 printf("%d", BT->Data); PrintLeaves(BT->Left); PrintLeaves(BT->Right); } }