后序:左右根
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
typedef struct node
{
char data;
struct node *L_Kid,*R_Kid;
}Tree;
void initTree(Tree *&T)
{
char str;
cin>>str;
if(str!='#')
{
T=(Tree *)malloc(sizeof(Tree));
T->data=str;
initTree(T->L_Kid);
initTree(T->R_Kid);
}
else T=NULL;
}
void Traverse(Tree *&T)
{
if(T!=NULL)
{
Traverse(T->L_Kid);
Traverse(T->R_Kid);
cout<<T->data;
}
}
int main()
{
Tree *T;
initTree(T);
Traverse(T);
return 0;
}