//遍歷算法 #include<iostream> using namespace std; typedef struct BiNode{ char data; struct BiNode *lchild,*rchild; }BiTNode,*BiTree; void CreratBiTree(BiTree &T){ char ch; cin>>ch; if(ch=='#') T=NULL; else{ T=new BiTree; T->data=ch; CreratBiTree(T->lchild); CreratBiTree(T->rchild) } } void InOderTraverserve(BiTree T){ if(T){ InOderTraverserve(T->lchild); cout<<T-data; InOderTraverserve(T->rchild); } } void main(){ BiTree tree; cout<<"please input\n"; CreratBiTree(tree); cout<<"middle result\n"; CreratBiTree(tree); cout<<"front result\n"; cout<<endl; }