SDUTACM 二叉树的层序遍历

来源:互联网 发布:淘宝新款男士长袖衬衣 编辑:程序博客网 时间:2024/06/04 19:16

直接上代码,简单明了,直接就可以用。

层序遍历子函数:

void cengxu(struct hh *root)
{
 int out=0,in=0;
struct hh *q[100];
q[in++]=root;
while(in>out)
{
    if(q[out]!=NULL)
 {
        printf("%c",q[out]->data);
        q[in++]=q[out]->l;
        q[in++]=q[out]->r;
 }
    out++;
}
}

0 0
原创粉丝点击