遍历二叉树出了问题!
编译过不去!void myprintf(node *Tree)
{
printf("\n%s,%d\n",Tree->data.ch,Tree->data.cs);
}
void preordertraverse(node *Tree, void (*p)(node *)) //先序遍历
{
if(Tree)
{
(*p)(Tree);
preordertraverse(Tree->lchild, (*p)(Tree->lchild));
preordertraverse(Tree->rchild, (*p)(Tree->rchild));
}
}
void inordertraverse(node *Tree, void (*p)(node *)) //中序遍历
{
if(Tree)
{
inordertraverse(Tree->lchild, (*p)(Tree->lchild));
(*p)(Tree);
inordertraverse(Tree->rchild, (*p)(Tree->rchild));
}
}
void postordertraverse(node *Tree, void (*p)(node *)) //后序遍历
{
if(Tree)
{
postordertraverse(Tree->lchild, (*p)(Tree->lchild));
postordertraverse(Tree->rchild, (*p)(Tree->rchild));
(*p)(Tree);
}
}
错误提示:
Compiling...
ben.c
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(176) : error C2095: 'preordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(176) : error C2198: 'preordertraverse' : too few actual parameters
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(177) : error C2095: 'preordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(177) : error C2198: 'preordertraverse' : too few actual parameters
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(185) : error C2095: 'inordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(185) : error C2198: 'inordertraverse' : too few actual parameters
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(187) : error C2095: 'inordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(187) : error C2198: 'inordertraverse' : too few actual parameters
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(195) : error C2095: 'postordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(195) : error C2198: 'postordertraverse' : too few actual parameters
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(196) : error C2095: 'postordertraverse' : actual parameter has type 'void' : parameter 2
d:\我的文档\procedure\树\benthy_tree\function_tree2.txt(196) : error C2198: 'postordertraverse' : too few actual parameters
Error executing cl.exe.
ben.obj - 12 error(s), 0 warning(s)
Benthy_tree.zip
(251.11 KB)