标题:我的程序那里错了……
只看楼主
andy36
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-11-5
 问题点数:0 回复次数:0 
我的程序那里错了……

# include <stdio.h>

typedef struct node

{ char data;

struct node *lchild,*rchild;

} BTNode;

#define NodeLen sizeof(BTNode)

BTNode *t;

main()

{ BTNode *creat_bintree(BTNode *t);

void visit(BTNode *t);

void preorder(BTNode *t );

void inorder(BTNode *t );

void postorder(BTNode *t );

t=creat_bintree(t);

if (t)

{ printf("\n after preorder:\n"); preorder(t);

printf("\n after inorder:\n"); inorder(t);

printf("\n after postorder:\n"); postorder(t);

}

}

BTNode *creat_bintree(BTNode *t)

{ char ch;

printf("\n enter ch in preorder, 1 for no child:");

ch=getchar(); getchar();
if ( ch=='@') t=NULL;

else { t = (BTNode *)malloc(NodeLen);

t->data=ch;

t->lchild = creat_bintree( t->lchild );

t->rchild = creat_bintree( t->rchild );

}

return(t);

}

void visit(BTNode *t)

{ putchar(t->data);

printf("\t");

}

/* preorder_tree() */

void preorder(BTNode *t )

{ if (t)

{ visit(t);

preorder(t->lchild);

preorder(t->rchild);

}

}

/* inorder_tree() */

void inorder(BTNode *t )

{ if (t)

{ inorder(t->lchild);

visit(t);

inorder(t->rchild);

}

}

/* postorder_tree() */

void postorder(BTNode *t )

{ if (t)

{ postorder(t->lchild);

postorder(t->rchild);

visit(t);

}

}

搜索更多相关主题的帖子: include visit 
2006-11-05 01:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-100810-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.077893 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved