⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 B树及其B+树的实现代码
💻 CPP
字号:
#include "head.h"
#include <iostream>
#include <ctime>

const int num = 1000;

int main() {
	using namespace std;
	srand((unsigned int) time(NULL));
	B_plus_Tree<int ,50> tree;
	int a[num];
	for (int i = 0; i < num / 2; i++) {
		a[i] = rand();
		tree.Insert(a[i]);
	}
	tree.Traverse(tree.Getroot());
	cout << "The height of the tree is " << tree.Height() << "." << endl;
	cout << "The tree contains " << tree.Num_of_Leaf() << " leaf nodes." << endl;

	for (int i = num / 2; i < num; i++) {
		a[i] = rand();
		tree.Insert(a[i]);
	}
	tree.Traverse(tree.Getroot());
	tree.Traverse();
	cout << "The height of the tree is " << tree.Height() << "." << endl;
	cout << "The tree contains " << tree.Num_of_Leaf() << " leaf nodes." << endl;

	for (int i = 0; i < num; i++)
		tree.Delete(a[i]);
	tree.Traverse(tree.Getroot());
	tree.Traverse();
	cout << "The height of the tree is " << tree.Height() << "." << endl;
	cout << "The tree contains " << tree.Num_of_Leaf() << " leaf nodes." << endl;

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -