0
void preorderTraversal(struct node*tree)
{

    if (tree != NULL)
    {
        printf("%d", tree->data);
        tree->left=preorderTraversal(tree->left);
        tree->right = preorderTraversal(tree->right);
    }
}
4

1 回答 1

3

函数preorderTraversal被声明void

也就是说,它不返回任何值。

但在这些方面:

tree->left = preorderTraversal(tree->left);
tree->right = preorderTraversal(tree->right);

您将它视为它返回一个可以分配给->left和的值->right

于 2020-12-05T04:04:01.420 回答