#include <stdio.h>
#include<stdlib.h>
#define max 100
typedef struct Tree{
int data;
struct Tree *lchild;
struct Tree *rchild;
int ltag,rtag;
} *tree,sree;
typedef struct node{
tree data[max];
int top;
}*list,List;
list Init()
{
list s=(list)malloc(sizeof (List));
if(s)
s->top=-1;
return s;
}
int Empty(list s){
if(s->top==-1)
return 1;
else {
return 0;
}
}
void push(list s,tree t)
{
if(s->top==max-1)
printf("栈满");
else {
s->top++;
s->data[s->top]=t;
}
}
void pop(list s,tree *t){
if(Empty(s))
printf("栈空");
*t=s->data[s->top];
s->top--;
}
void Treeinit(tree *t,char *str ,int *x)
{
char ch;
ch=*(str+*x);
*x=*x+1;
if(ch!='#'){
*t=(tree)malloc(sizeof (sree));
(*t)->data=
二叉树的中序线索化
最新推荐文章于 2024-04-29 19:53:30 发布