📄 btree.h
字号:
#ifndef __BTREE
#define __BTREE
#include <iostream.h>
#include <iomanip.h>
#include <ctype.h>
#include <string.h>
#define M 3 // B-树的阶
#define borrower_num 1000 //借书人数量
typedef int dtype; //BookID的类型
enum status
{Insert_not_complete, Success, Duplicate_key, Underflow, Not_found};
class Book
{
public:
Book(void);
void show()
{
cout<<"书名:"<<name<<endl
<<"作者:"<<writer<<endl
<<"现存:"<<nowNum<<endl
<<"库存:"<<totalNum<<endl;
}
dtype bookID;//本程序中,id作为索引
char name[20];
char writer[20];
int nowNum;
int totalNum;
};
class Borrower
{
public:
Borrower(void);
int borrower_id; //借阅者的图书证号
int year;
int month;
int day; /* 借阅日期 */
int deadline;
dtype key; /* 所借图书内容 */
};
class B_node {
public:
B_node() {}
int n;
dtype k[M-1];
Book books[M-1];
B_node *p[M];
};
class B_tree {
public:
B_tree():root(NULL){}
void insert(dtype x);
void print() const {cout << "B-tree 输出:\n"; pr(root, 0);}
void Del_Node(dtype x);
void Show_Search (dtype x) const;
int Borrow(dtype x);
int Return(dtype x);
void Display(dtype x);
private:
B_node *root;
status ins(B_node *r, dtype x, dtype &y, B_node* &u);
void pr(const B_node *r, int n_Space) const;
int Node_Search(dtype x, const dtype *a, int n) const;
status del(B_node *r, dtype x);
};
#endif // __BTREE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -