首先根据前序和中序构造一棵二叉树,然后利用中序遍历和广度优先将树按照形状打印出来。 #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX 1000 /* print the tree first:using the preorder and inoder,create a tree then print it using bst and preorder */ int i=1; //标记中序中的顺序 //队列的简单实现 struct node * queue[MAX];//队列 ,未考虑溢出 int head = 0; int tail = 0; struct node * dequeue(){ struct node * temp = queue[head]; head++; head %= MAX; return temp;read more