广度优先遍历二叉树
//q是定义的队列
q[N] = 110;
//u是根节点
void bfs(int u)
{
int hh, tt;
hh = tt = 0;
q[0] = u;
//l,r是用hash存储节点的左右孩子
while(hh <= tt)
{
int root = q[hh ++];
if(l[root) q[++ tt] = l[root];
if(r[root) q[++ tt] = r[root];
}
cout << q[0];
for(int i = 1; i < n; ++ i) cout << q[i];
return;
}