一. 试验题目:二叉树
二. 试验要求:从键盘输入先序序列,以二叉链表作为储存结构,建立二叉树(以先序来建立)
并对其进行遍历(先序、中序、后序),然后将遍历结果打印输出。要求采用递归和非递归两种方
法来实现。
三. 试验内容:
#include <stdio.h>
typedef struct node {
char data;
struct node * Lchild;
struct node * Rchild;
}Binode,* Bitree;
typedef struct {
Bitree data[20];
int top;
}Stack;
void init();
void init2();
void creat(Bitree * root);
void preprint(Bitree root);
void inprint(Bitree root);
void postprint(Bitree root);
void Push(Stack * s,Bitree x);
void Pop(Stack * s,Bitree * x);
void pre2(Bitree root);
void in2(Bitree root);
void post2(Bitree root);
void main()
{
char choose;
init();
printf(" choose the way you want:");
choose=getchar();
getchar();
printf("");
switch(choose)
{
case '0':printf("Thanks for your use");break;
case '1':{