文章

70

粉丝

0

获赞

272

访问

48.9k

头像
二叉树的建立和遍历 题解:
P1109 同济大学机试题
发布于 2026年3月
阅读数 710

#include<stdio.h>
#include<iostream>

using namespace std;


typedef struct Node{
    char data;
    Node *lc,*rc;
}*Bitree;


void creattree(Bitree& T){
    char x;
    cin >> x;
    if(x=='0') return;
    else{
        T = new Node;
        T->data = x;
        T->lc = NULL;
        T->rc = NULL;
        creattree(T->lc);
        creattree(T->rc);
    }
}


void visit(Node* &p){
    if(p!=NULL)    cout<<p->data<<" ";
}


void Preorder(Bitree &T){
    if(T!=NULL){
        visit(T);
       &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发