从前98 2021-11-28 18:54 采纳率: 100%
浏览 15
已结题

VS软件错误提示creatBSTree(&rood)函数的调用中参数太多,且creatbstree函数不接受一个参数怎么解决

#include <stdio.h>
#include <stdlib.h>
typedef int datatype;
typedef struct node {
datatype key;
struct node* lchild, * rchild;
} BSTnode;
typedef BSTnode * BSTree;
//插入结点,并对结点进行判断,确定插入左子树还是右子树
//基于二叉排序树的结点的插入算法
void InsertBSTree(BSTree* t, datatype x)
{
BSTree f = NULL, p;
p = *t;
while (p)
{
if (x == p->key)return;
f = p;
p = (x < p->key) ? p->lchild : p->rchild;
}
p = (BSTree)malloc(sizeof(BSTnode));
if (p != NULL)
{
p->key = x;
p->lchild = p->rchild = NULL;
}
if (*t == NULL) *t = p;
else
if (x < f->key)
f->lchild = p;
else f->rchild = p;
}
//从键盘输入元素的值,创建相应的二叉排序树
BSTree creatBSTree(void)
{
BSTree t = NULL;
datatype key;
printf("\n请输入一个以-1为结束标志的结点序列;\n");
scanf_s("%d", &key);
while (key != -1)
{InsertBSTree(&t,key);
scanf_s("%d", &key);
}
return t;
}
//逆中序遍历从大到小输出二叉树结点,即先遍历右子树,然后根,最后左子树
void Inorder(BSTree rood)
{
if (rood)
{

    //  先序遍历右子树
    Inorder(rood->rchild);
    //  访问根节点
    printf("%d\n",rood ->key);
    //  先序遍历左子树
    Inorder(rood->lchild);
} 

}
int main()
{
BSTree rood{};
creatBSTree(&rood);
printf("结果序列为:\n");
Inorder(rood);
return 0;
}

  • 写回答

1条回答 默认 最新

  • CSDN专家-link 2021-11-28 19:21
    关注

    BSTree creatBSTree(void)
    这个函数你定义的是无参函数啊

    main函数中的调用改为
    BSTree rood = creatBSTree();就行了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月6日
  • 已采纳回答 11月28日
  • 创建了问题 11月28日

悬赏问题

  • ¥15 扫描枪扫条形码出现问题
  • ¥15 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 【火车头采集器】搜狐娱乐这种列表页网址,怎么采集?
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3
  • ¥15 我的R语言提示去除连锁不平衡时clump_data报错,图片以下所示,卡了好几天了,苦恼不知道如何解决,有人帮我看看怎么解决吗?
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?