递归实现:
#include<iostream> using namespace std; typedef struct node { struct node *leftChild; struct node *rightChild; char data; }BiTreeNode, *BiTree; void createBiTree(BiTree &T) { char c; cin >> c; if('#' == c) T = NULL; else { T = new BiTreeNode; T->data = c; createBiTree(T->leftChild); createBiTree(T->rightChild); } } int main() { BiTree T; createBiTree(T); return 0; }