| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 607 人关注过本帖
标题:二叉数的储存及先序遍历
只看楼主 加入收藏
luo113927
Rank: 1
等 级:新手上路
帖 子:173
专家分:0
注 册:2006-3-15
收藏
 问题点数:0 回复次数:0 
二叉数的储存及先序遍历

请大家帮偶看看这程序到底怎么啦!!!!
怎么老出错,大家可以运行一下

#include <stdio.h>
#include <stdlib.h>

typedef char datatype;
typedef struct BiNode
{
datatype data;
struct BiNode *lchild, *rchild;
}BiNode, *BiTree;

int scantree ( BiTree T );
int intertree ( BiTree *T );

void main()
{
BiTree T=NULL;
intertree( &T );
printf("先序遍历的结果是: ");
scantree ( T );
getch();
}

int intertree( BiTree *T )
{
datatype x;
scanf("%c",&x);
if( x=='/' )(*T)=NULL;
else
{
if( !((*T)=( BiNode *)malloc(sizeof(BiNode)) ))
return (0);
(*T)->data=x;
intertree( &((*T)->lchild) );
intertree( &((*T)->rchild) );
}
return (1);
}

int scantree( BiTree T )
{
if( T )
{
printf("%c",T->data);
if( scantree( T->lchild ) )
if( scantree( T->rchild ) )
return(1);
else
return(0);
}
else
return(1);
}

[此贴子已经被作者于2006-4-9 23:36:44编辑过]

搜索更多相关主题的帖子: 遍历 储存 
2006-04-09 22:57
快速回复:二叉数的储存及先序遍历
数据加载中...
 
   



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

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