void level(tree* node )
{
tree* temp=node;
queue<tree*>tp;
tp.push(temp);
while (!tp.empty())
{
cout << tp.front()->date << " ";
if (tp.front()->lchild != NULL)
{
tp.push(tp.front()->lchild);
}
if (node->rchild != NULL)
{
tp.push(tp.front()->rchild);
}
tp.pop();
}
}
数据结构->(树层次遍历)
最新推荐文章于 2024-09-09 23:14:05 发布