博前感想:
图书管理系统是我们数据结构实验的最后一个也是综合类实验。其中涉及到二叉树的查找,排序,存储。以及对邻接表的应用。
这个实验没有做到二叉平衡,也就是没有做到AVL树。还有写瑕疵就是代码会有冗余。
代码:
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<vector>
#include<fstream>
using namespace std;
ifstream fin("图书管理系统测试数据2.txt");
typedef struct Book
{
string name;
string bid;
string writer;
string date;
Book *lc, *rc, *parent, *next;
int now; //struct stu;
int summary; //stu *visit;
int key;
}B_list, *book;
typedef struct stu
{
string name;
book bl[26]; //存自己借的书
string sid;
book first; //用于访问书结构体的指针
int booknum;
}S_list, *student;
typedef struct graph_s //学生查书的图
{
S_list sl[26]; //已经创建了26个学生的数组
int s_num; int b_num;
//book bl[26]; //书本采用两种方式存储,一种树状结构,一种链式结构,链式结构用于查找.
}g_s_list;
book original;
void find_index(book h,book hh, g_s_list w); //先声明一下
void digui_create(book &bo, g_s_list &w)
{
string ch;
cout << "请输入书名(%代表没有这种书)" << endl;
cin >> ch;
if (ch == "%") //输入的时候最好一次输入一个换行,别加空格
{
bo = NULL;
}
if (bo)
{
bo = new Book;
bo->name = ch;
digui_cre