文章

82

粉丝

343

获赞

27

访问

657.9k

头像
先重建树 然后两个方向递归
P1551 东北大学机试题
发布于2021年2月1日 14:43
阅读数 8.4k

#include<iostream>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef struct node{
    char data;
    struct node*lchild;
    struct node*rchild;
}BiNode,*BiTree;

queue<BiTree> q;
BiTree build(){
    char c;
    cin>>c;
    BiTree root=new node;
    root->data=c;
    q.push(root);
    while(!q.empty()){
        BiTree t=q.front();
        q.pop(); 
        cin>>c;
        if(c=='#'){
            t->lchild=NULL;
        }
        else{
            BiTree xx=new node;
&n...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发