数据结构--图书管理系统

本文介绍了在数据结构实验中实现的图书管理系统,该系统利用二叉树进行查找、排序和存储操作,并应用了邻接表。虽然未实现AVL树平衡,且存在代码冗余问题,作者期待通过分享和交流,与读者共同进步。
摘要由CSDN通过智能技术生成

博前感想:

图书管理系统是我们数据结构实验的最后一个也是综合类实验。其中涉及到二叉树的查找,排序,存储。以及对邻接表的应用。

这个实验没有做到二叉平衡,也就是没有做到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_create(bo->lc, w);
		digui_create(bo->rc, w);
	}
}
  • 10
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值