You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
3 years ago | |
|---|---|---|
| README.md | 3 years ago | |
README.md
dadsadsad
#include<stdio.h> #include using namespace std; typedef struct bi{ char data; struct bi *lchild,*rchild; }tree,*btree;
void csh(bi* &d){ char ch; cin >> ch; if(ch == '#') d=NULL; else { d = new bi; d->data=ch; csh(d->lchild); csh(d->rchild); } }
void xx(bi* &t){ if(t){ cout << t->data; xx(t->lchild); xx(t->rchild); } }
void zx(bi* &t){ if(t){ zx(t->lchild); cout << t->data; zx(t->rchild); } }
void hx(bi* &t){ if(t){ hx(t->lchild); hx(t->rchild); cout << t->data; } }
int main(){ btree d; cout << "通过先序遍历创建二叉树,#表示空节点" << endl; csh(d); xx(d); cout << "" <<endl; zx(d); cout << "" <<endl; hx(d); cout << "" <<endl; }