#include<stdio.h>
#include<malloc.h>
#include<iostream>
//
typedef struct BiNode{
char data;
struct BiNode *lch;
struct BiNode *rch;
}BiNode,*BiTree;
//
void Create(BiTree &T)
{
T =(BiNode*) malloc (sizeof(BiNode));
printf("Enter the data
");
scanf(" %c",&T->data);
if(T->data=='#') T = NULL;
if(T){
printf("");
Create(T->lch);
Create(T->rch);
}
}
// ( )
void Preorder (BiTree T)
{
if (T) {
printf(" %c",T->data); //
Preorder(T->lch); //
Preorder(T->rch);//
}
}
// ( )
void Inorder (BiTree T)
{
if(T) {
Inorder(T->lch);
printf(" %c",T->data);
Inorder(T->rch);
}
}
// ( )
void Postorder (BiTree T)
{
if(T) {
Postorder(T->lch);
Postorder(T->rch);
printf(" %c",T->data);
}
}
int main()
{
//
printf("The fuction Create() is called.
");
BiTree T;
Create(T);
//
printf("
");
printf("The fuction Preorder() is called.
");
Preorder(T);
printf("
");
printf("The fuction Inorder() is called.
");
Inorder(T);
printf("
");
printf("The fuction Postorder() is called.
");
Postorder(T);
printf("
");
system("pause");
}