C语言二叉树结构数组法
来源:互联网 发布:php登录页面完整代码 编辑:程序博客网 时间:2024/06/15 05:50
#include "stdafx.h"struct tree{int left;int data;int right;};typedef struct tree treenode;const int num = 32768;treenode tree[num];int _tmain(int argc, _TCHAR* argv[]){int n = 9;int x = 1;int i;int num[10] = {6,3,8,5,2,9,4,7,10};tree[1].data = num[0];tree[1].left = -1;tree[1].right = -1;for ( i= 2; i < 10; i++){tree[i].left = -1;tree[i].right = -1;tree[i].data = 0;}for (i = 1; i < 9; i++){x = 1;while (tree[x].data != 0){if (num[i] < tree[x].data){if (tree[x].left == -1){tree[x].left = i + 1;x = i + 1;tree[x].data = num[i];break;}else {x = tree[x].left;}}else {if (tree[x].right == -1){tree[x].right = i + 1;x = i + 1;tree[x].data = num[i];break;}else {x = tree[x].right;}}}}for (int i = 1; i < 10; i++){printf("%d%d%d\n", tree[i].left, tree[i].data, tree[i].right);}return 0;}
0 0
- C语言二叉树结构数组法
- c语言构造数组二叉树
- 二叉树结构数组表示法
- C语言结构体数组
- C语言结构体数组
- C语言结构体数组
- C语言 二叉树的结构和遍历算法
- 数据结构C语言实现之二叉树链式结构
- 二叉树的顺序结构C语言实现
- C语言 将二叉树转化为数组
- C语言 二叉树
- c语言 二叉树
- 二叉树(C语言)
- c语言二叉树
- C语言 二叉树
- 二叉树-C语言
- 二叉树C语言
- C语言结构体数组赋值问题
- Android “Theme.AppCompat.Light”解决方法
- Java小对象优化
- FPGA规范及该注意的地方
- Paint、Canvas实例自定义绘制ArcProgressBar
- 【JZOJ4915】最长不下降子序列
- C语言二叉树结构数组法
- 复选框checkbox 获取已选中的值
- 2016 工作、生活与得失
- mybatis 中 foreach collection的三种用法
- Verilog HDL 语言书写规范
- 算法导论——2.3-2无哨兵情况下的归并排序
- leetcode——2Add Two Numbers
- 手动将jar文件加到Maven的local repository中
- GIT 第一问 怎么删除github上的仓库