前提是将二叉树扩充为完全二叉树
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
typedef struct bitree *Bnode; struct bitree{ int data; Bnode left,right; }; Bnode CreateTree(){ Bnode q[105]; int f=1,r=0; int num; Bnode root=NULL,s; while(scanf("%d",&num)&&num!=-1){ if(num==0)s=NULL; else{ s=(Bnode)malloc(sizeof(bitree)); s->data=num;s->left=NULL;s->right=NULL; } q[++r]=s; if(r==1)root=s; else{ if(q[f]&&s){ if(r%2==0) q[f]->left=s; else q[f]->right=s; } if(r%2==1)f++; } } return root; }