<span style="font-size:14px;">#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct BtNode
{
int value;
struct BtNode *lchild;
struct BtNode *rchild;
}BtNode, *Bitree;
Bitree newBtNode()
{
Bitree p = new BtNode;
if( NULL == p )
{
cout << "newBtNode func: err -1, NULL==p " << endl;
return p;
}
p->value = 0;
p->lchild = p->rchild = NULL;
return p;
}
int createBitree( Bitree *head )
{
int ret = 0;
if( NULL == head )
{
cout << "createBitree func: err -1, NULL==head" << endl;
ret = -1;
return ret;
}
int data = 0;
cin >> data;
if( 0 == data ) // leaf
{
*head = NULL;
}
else
{
*head = newBtNode();
(*head)->value = data;
createBitree( &( (*head)->lchild ) );
createBitree( &( (*head)->rchild ) );
}
return ret;
}
void preTravel( Bitree head )
{
if( head != NULL )
{
cout << head