本来不想往blog上面贴一大堆代码的,不过好不容易写出来了,贴出来给大家做个参考把!

程序输入一连串的整数序列,会根据这个整数序列构建一个平衡二叉树。

1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include <stdlib.h>
//节点数据结构
struct node{
int val;//值
int bf;//平衡因子
struct node* left;
struct node* right;
};