//BTreeNode.h
//B-树节点实现
//2006.6.20
//write by :宋瑞丰
//email:gordonbest@163.com
//////////////////////////////////////
初学者,见笑
//////////////////////////////////////
本程序支持不同阶数的b-树
BTreeNode.h和BTreeNode.cpp是树节点结构的代码
BTree.h和BTree.cpp树结构的代码
TestDlgDlg.h和TestDlgDlg.cpp是显示树结构的代码
具体函数信息请参看函数声明和定义
************************************************************************************
请设置project为不使用提前预编译选项
project->setting->c/c++->category(选precompiled headers)->not using precompiled headers
否则可能有编译错误,具体原因我也不知道(晕!)
************************************************************************************
这个程序没有做到内存释放,重画树结构的时候效率可能不好,您有好的改进,请通知我啊
*************************************************************************************
BTreeNode.h
BTreeNode.cpp
BTree.h
BTree.cpp
这4个文件可以在console(就是黑屏)模式下运行
只需新建一个工程,加入以上文件(如果使用相同文件名,可不修改代码,直接运行)
再加入一个cpp文件
内容如下:
#include "BTree.h"
#include <iostream>
#include <algorithm>
#include <list>
#include <time.h>
using namespace std;
int main(){
BTree btree;
cout<<"*******************************************\n";
cout<<"插入:1 删除:2 显示:3 结束:-1\n";
int doEvent=-1;
cin>>doEvent;
int inValue=0;
int deValue=0;
while(doEvent!=-1){
switch(doEvent) {
case 1:
do {
cout<<"*******************************************\n";
cout<<"输入插入数据:(-1结束)\n";
cin>>inValue;
if(btree.Find(inValue)!=NULL)
cout<<"已经存在";
if(inValue!=-1)
btree.Insert(inValue);
btree.Display();
} while(inValue!=-1);
break;
case 2:
do {
cout<<"*******************************************\n";
cout<<"输入删除数据:(-1结束)\n";
cin>>deValue;
if(deValue!=-1)
btree.Erase(deValue);
btree.Display();
} while(deValue!=-1);
break;
case 3:
btree.Display();
break;
default:
//doNothing
break;
}
cout<<"*******************************************\n";
cout<<"插入:1 删除:2 显示:3 结束:-1\n";
cin>>doEvent;
}
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
B树演示程序.rar (25个子文件)
B-树演示程序
Resource.h 1KB
TestDlg.rc 7KB
Release
TestDlg.plg 2KB
res
TestDlg.ico 1KB
TestDlg.rc2 399B
TestDlg.aps 21KB
code999.com说明.txt 2KB
BTree.exe 40KB
TestDlg.dsw 539B
TestDlg.clw 2KB
TestDlg.dsp 4KB
BTree.h 5KB
TestDlg.opt 51KB
StdAfx.cpp 209B
TestDlgDlg.cpp 14KB
BTreeNode.cpp 5KB
TestDlg.cpp 2KB
TestDlg.h 1KB
BTreeNode.h 5KB
三九源码.url 169B
StdAfx.h 1KB
TestDlg.ncb 145KB
Debug
TestDlgDlg.h 2KB
BTree.cpp 9KB
ReadMe.txt 2KB
共 25 条
- 1
资源评论
- tblucelzw2013-03-07可以实现,不错!!!
bowenzlx
- 粉丝: 1
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功