文章

25

粉丝

0

获赞

210

访问

5.4k

头像
二叉排序树 - 华科 题解:
P1396 华中科技大学
发布于2026年3月6日 15:33
阅读数 163

#include<bits/stdc++.h>
using namespace std;

typedef struct node{
    int data;
    struct node * lchild;
    struct node * rchild;
}*BitTree;

void create_tree(BitTree &T, int x){
    if(T == NULL){
        T = new node;
        T -> data = x;
        T -> lchild = NULL;
        T -> rchild = NULL;
        return;
    }

    if(x == T -> data){
        return;
    }else if(x < T -> data){
        create_tree(T->lchild, x);
    }else{
        create_tree(T->rchild, x);
    }
}

int main(){
    int n;
    while(cin >> n){
        BitTree root = NULL;

        for(int i = 0; i < n; i++){
    &nb...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发