文档介绍:#include <iostream>
#include <string>
using namespace std;
struct Reader
{
string name;
string number;
string dateBorrow;
string dataBack;
Reader *next;
};
struct Book
{
string title;
string writer;
int amount;
int curAmount;
float price;
string number;
Reader reader;
Book *next;
};
struct Type
{
string name;
int amount;
Book book;
Type *next;
};
struct Library
{
int amount;
int amountBorrowed;
Type type;
};
//书籍类别的插入,头结点后插入
void typeInsert(Type *t,string na)
{
Type *p = new Type;
p->name = na;
p->amount = 0;
p-> = NULL;
p->next = t->next;
t->next = p;
}
//对图书的分类进行初始化
void init(Library *l)
{
l->amount = 0;
l->amountBorrowed = 0;
l-> = NULL;
//插入4个书籍类别
typeInsert(&l->type,"TG");
typeInsert(&l->type,"TK");
typeInsert(&l->type,"TP");
typeInsert(&l->type,"TM");
}
void bookInsert(Book *b)
{
//创建节点
int n=0;
Book *p = new Book;
//输入书名
printf("Input Title:");
cin>>p->title;
//输入作者
printf("Input writer:");
cin>>p->writer;
//判断是否书籍已存在
while(b->next != NULL)
{
if(b->next->title ==p->title && b->next->writer == p->writer)
{
printf("The book existed\n");
b->next->amount+=1;
b->next->curAmount+=1;
printf("Entry finished\n");
n = 1;
}
b = b->next;
}
//输入价格
if(n == 0)
{
printf("Input price:");
cin>>p->price;
//输入图书编号
printf("Input number:");
cin>>p->number;
//读者链暂时为空
p-> = NULL;
p->amount = 1;
p->curAmount = 1;
//节点链入
p->next = NULL;
b->next = p;
}
}
void readerInsertNode(Reader *r)
{
//新建节点
Reader *p = new Reader;
//录入数据
printf("Input name:");
cin>>p->name;
printf("Input number:");
cin>>p->number;
printf("Input dateBorrow:");
cin>>p->dateBorrow;
printf("Input dateBack:");
cin>>p->dataBack;
//链入节点
while(r->next)
{
r = r->next;
}
p->next = NULL;
r->next = p;
}
void readerInsert(Book *b)
{
string title,writer;
int n = 0;
cout<<"你想为那本书籍添加借阅者?\n