推荐回答
先序创建一颗二叉树遍历;#include#include#include#defineOVERFLOW-2#defineOK1#defineERROR0typedefintstatus;typedefcharTElemtype;typedefstructBiTNode{TElemtypedata;structBiTNode*lchild,*rchild;}BiTNode,*BiTree;statusVisitTElemtypee{printf"%c",e;returnOK;}voidInoRtraverseBiTreeT,status*VisitTElemtype{ifT{InoRtraverseT->lchild,Visit;VisitT->data;InoRtraverseT->rchild,Visit;}}voidPosTtraverseBiTreeT,status*VisitTElemtype{ifT{PosTtraverseT->lchild,Visit;PosTtraverseT->rchild,Visit;VisitT->data;}}statuscreatBiTreeBiTree*T{charc;scanf"%c",&c;ifc==''''*T=NULL;else{if!*T=BiTNode*mallocsizeofBiTNodeexitOVERFLOW;*T->data=c;creatBiTree&*T->lchild;creatBiTree&*T->rchild;}returnOK;}voidmain{BiTreeT;creatBiTree&T;printf"按照中序排列输出";InoRtraverseT,Visit;printf"按照后序排列输出";PosTtraverseT,Visit;。
齐晓洁2019-12-21 18:41:57
提示您:回答为网友贡献,仅供参考。