#include using namespace std;#define Status int #define OK 1#define ERROR 0#define Elemtype chartypedef enum{link,Thread}PointerTag;typedef struct BiThrNode{Elemtype data;struct BiThrNode *lchild, *rchild; struct BiThrNode *parent;PointerTag LTag , RTag; }BiThrNode, *BiThrTree;BiThrTree pre; Status visit(Elemtype e){cout << e << endl;return OK;}char Vexch[26]={'A','B','D','H','$','$','I','$','$','E','J','$','$','$','C','F','$','$','G','$','$'}; int i=0; Status CreatBiThrTree(BiThrTree &T, BiThrTree &p) { if(Vexch[i++]=='$') T=NULL; else { T= new BiThrNode; if(!T) return 0; T->data=Vexch[i-1]; T->parent = p;T->LTag=link; CreatBiThrTree(T->lchild, T);T->RTag=link; CreatBiThrTree(T->rchild, T); } return 1; } void PostThreading(BiThrTree p) {if(p) {PostThreading(p->lchild); PostThreading(p->rchild); if(!p->lchild) { p->LTag = Thread; p->lchild = pre; }if(pre && !pre->rchild) {pre->RTag = Thread; pre->rchild = p ; }pre = p;}}Status PostOrderTraverse_Thr(BiThrTree T) {BiThrTree p;p = T; pre=NULL;while(p != NULL){ while(p->LTag == link) p = p->lchild; while(p->RTag == Thread) { visit(p->data);pre = p;p = p->rchild ; }if(p == T){ visit(p->data); break;}while(p && p->rchild == pre) { visit(p->data);pre = p;p = p->parent;}if(p && p->RTag == link)p = p->rchild;}return OK;}int main() {BiThrTree PostT;pre = NULL;CreatBiThrTree(PostT,pre);PostThreading(PostT);PostOrderTraverse_Thr(PostT);printf("n");return 0;}