原创代码,如有错误,欢迎指正。
阅读建议:请先迅速浏览函数申明部份,然后再从 main 函数看起。
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# define ElemType char
# define MAX_SIZE 20
# define true 1
# define false 0
typedef int bool;
typedef struct Tree node;
typedef struct Tree *pnode;
typedef struct Stack stack;
typedef struct Stack *pstack;
// stack
struct Stack {
pnode *list;
int size;
int now;
};
// tree
struct Tree {
ElemType data;
struct Tree *lnode, *rnode;
};
// tree
pnode CreateNode(); // 创建结点,并初始化。但未向结点赋值
void preOrder(pnode root); // 这三个函数是遍历树的。先序pre,中序in,后序post
void inOrder(pnode root);
void postOrder(pnode root);
// stack
pstack CreateStack(); //