文件名称:1111
- 所属分类:
- 数据结构常用算法
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 1.12mb
- 下载次数:
- 0次
- 提 供 者:
- 陈*
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
二叉树的建立演示,可以将你输入的数字建立完全的二叉树-#include <stdio.h>
#include <string.h>
#include <windows.h>
struct BTree {
int data
struct BTree* left
struct BTree* right
} //end struct BTree
BTree* CreateLeaf(int number)
{
BTree* l = new BTree
l->data = number
l->left = 0
l->right = 0
return l
}//end CreateLeaf
void append(BTree** root, int number)
{
if (!root) return
BTree* t =*root
if (!t) {
*root = CreateLeaf(number)
return
}//end if
while(t) {
if(number == t->data ) return //ignore duplicated elements.
if(number < t->data ) {
if(!t->left ) {
t->left = CreateLeaf(number)
return
}//end if
t = t->left
}else{
if(!t->right ) {
t->right = CreateLeaf(number)
return
}//end if
t = t->right
}//end if
}//end while
}//end append
void PrintLeaf(const BTree* root)
{
if (!root) return
if (root->left ) PrintLeaf(root->left )
printf(" d\t", root->data)
if (root->right ) PrintLeaf(root->right )
#include <string.h>
#include <windows.h>
struct BTree {
int data
struct BTree* left
struct BTree* right
} //end struct BTree
BTree* CreateLeaf(int number)
{
BTree* l = new BTree
l->data = number
l->left = 0
l->right = 0
return l
}//end CreateLeaf
void append(BTree** root, int number)
{
if (!root) return
BTree* t =*root
if (!t) {
*root = CreateLeaf(number)
return
}//end if
while(t) {
if(number == t->data ) return //ignore duplicated elements.
if(number < t->data ) {
if(!t->left ) {
t->left = CreateLeaf(number)
return
}//end if
t = t->left
}else{
if(!t->right ) {
t->right = CreateLeaf(number)
return
}//end if
t = t->right
}//end if
}//end while
}//end append
void PrintLeaf(const BTree* root)
{
if (!root) return
if (root->left ) PrintLeaf(root->left )
printf(" d\t", root->data)
if (root->right ) PrintLeaf(root->right )
(系统自动生成,下载前可以参看下载内容)
下载文件列表
新建文件夹\Debug\vc60.idb
..........\.....\vc60.pdb
..........\.....\平衡二叉树.exe
..........\.....\平衡二叉树.ilk
..........\.....\平衡二叉树.obj
..........\.....\平衡二叉树.pch
..........\.....\平衡二叉树.pdb
..........\平衡二叉树.cpp
..........\平衡二叉树.dsp
..........\平衡二叉树.dsw
..........\平衡二叉树.ncb
..........\平衡二叉树.opt
..........\平衡二叉树.plg
..........\Debug
新建文件夹
..........\.....\vc60.pdb
..........\.....\平衡二叉树.exe
..........\.....\平衡二叉树.ilk
..........\.....\平衡二叉树.obj
..........\.....\平衡二叉树.pch
..........\.....\平衡二叉树.pdb
..........\平衡二叉树.cpp
..........\平衡二叉树.dsp
..........\平衡二叉树.dsw
..........\平衡二叉树.ncb
..........\平衡二叉树.opt
..........\平衡二叉树.plg
..........\Debug
新建文件夹