文章

37

粉丝

67

获赞

3

访问

8.7k

头像
二叉排序树2 题解:简单代码如下:
P1411 华中科技大学机试题
发布于2024年3月9日 19:40
阅读数 229

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

struct node {
    int data;
    struct node* left, * right;
};


struct node* insertTree(struct node* T,int x) {
    if (T == NULL) {//创建结点
        T = (struct node*)malloc(sizeof(struct node));
        T->data = x;
        T->left = NULL;
        T->right = NULL;
    }
    else {
        if (x < T->data) {
            //往左子树走
            T->left = insertTree(T->left, x);
        }
        else if (x > T->data) {
            /...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发