请大家帮偶看看这程序到底怎么啦!!!!
怎么老出错,大家可以运行一下
#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编辑过]