文章
82
粉丝
344
获赞
201
访问
758.4k
#include <iostream>
using namespace std;
 
struct node{
    char data;
    struct node*left;
    struct node*right;
};
int k;
node* build(){
    char c;
    cin>>c;
    if(c=='0') return NULL;
    node* x=new node;
    x->data=c;
    x->left=build();
    x->right=build();
    return x;
}
void pre_order(node *t){
    if(t==NULL) return ;
    if(t->left==NULL&&t->right==NULL) k++;
    cout<<t->data<<" ";
    pre_order(t->left);
    pre_order(t->right);
}
void mid_order(node *t){
    if(t==NULL) return ;
    mid_order(t->left);
    cout<<t->data<<" ";
   &nb...
登录后发布评论
暂无评论,来抢沙发