#include <stdio.h>
#include <stdlib.h>typedef char BiElemType;
typedef struct BiTNode {BiElemType data;struct BiTNode *lChild;struct BiTNode *rChild;//左右节点
} BiTNode, *BiTree;
//辅助队列
typedef struct tag {BiTree p;//树的某一个节点,指针类型,保存申请节点的指针struct tag *pnext;
} tag_t, *ptag_t;int main() {BiTree p;//指向新申请的树节点BiTree tree = NULL;//初始化根节点//队头,队尾,新节点,新节点父元素ptag_t phead = NULL, ptail = NULL, listpnew = NULL, pucr = NULL;char c;while (scanf("%c", &c)) {printf("213");if (c == '\n') {break;;}p = (BiTree) calloc(1, sizeof(BiTNode));p->data = c;listpnew = (ptag_t) calloc(1, sizeof(tag_t));//给队列节点申请空间listpnew->p = p;if (tree == NULL) {tree = p;//第一个节点既是队列头也是队列尾phead = listpnew;ptail = listpnew;pucr = listpnew;} else {ptail->pnext = listpnew;ptail = listpnew;//将数放入左孩子if (pucr->p->lChild == NULL) {pucr->p->lChild = p;} else if (pucr->p->rChild == NULL) {pucr->p->rChild = p;pucr = pucr->pnext;}}}return 0;
}