#include<stdio.h>
#include<malloc.h>
struct node
{ int data;
struct node *lch;
struct node *rch;
};typedef struct node bitree;
bitree *creat()
{ bitree *t;int x;
scanf(" %d",&x);
if(x==0)
t=NULL;
else
{ t=(bitree*)malloc(sizeof(bitree));
t->data=x;
t->lch=creat();t->rch=creat();}
return t;
}
void inorder(bitree *root)
{ bitree *p; int top=0 ; bitree *stack[20];
p=root;
while(p!=NULL||top!=0)
{ if(p!=NULL)
{
top=top+1;
stack[top]=p;
p=p->lch;}
else
{ p=stack[top];
top=top-1;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载