题目关键是:通过输入的数组,构建一棵完全二叉查找树。
算法:(要注意数据大小非常重要,初始化的时候tree[1000]都会不能全部通过,改成tree[1010]才给我过的)
- 将输入的数组从小到大排序好,放入number数组;
- 弄一个tree[ ]数组,对此数组进行中序遍历。
- 每次遍历就将number数组中的值一次抓一个的放入进这个tree数组中即可。
比较巧妙,要多多体会
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <vector>
#include <cstring>
#include