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

📄 bookmanage.txt

📁 图书管理系统 1、 每种图书的登记内容包括书名、书号、作者、现存量和总库存量。 2、 系统应实现的操作及其功能: 1、 采编入库:新购入一种书
💻 TXT
字号:
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
class book
{
public:
	int num;//书号
	string name;//书名
	string author;//书作者
	int stock;//现存量
	int count;//总量
	book *next;
};
class ku
{
public:
	string name;// 类名称
	book *first;// 第一本书
};
class regist
{
public:
	string name;//借阅者姓名
	int no;//借阅者学号
	string bookname;//借阅的书名
	string enddata;//最晚归还日期
	regist *next;

};
void logo()
{
	cout<<"      ┬┴┬┌─ ●─┬─  │─┼─┐ ●├─┤○        "<<endl;
    cout<<"      ┴┬┴├┬ ┌─┼─ │◎ │ │ ○└┬┘●        "<<endl;
    cout<<"      ─┼─││ │ │  ││─┴─┴ ──┼──        "<<endl;
    cout<<"      ●│○││ ┴─┼─  │○  ● / │ \        "<<endl;
	cout<<"  °★.☆° .★?°∴°★.°?∴°☆ ?°∴° ☆..?   "<<endl;
	cout<<"   /\~~~~~~~~~~~~~\ ◆    ^*^   ☆     $$ .☆  "<<endl;
	cout<<"  ./ \~~~■~~~~~~~~\ ◆  *           *    $◢◣$  * "<<endl;
	cout<<"  / ^^ \ ══════\.◆    * *    *    $◢★◣$  *"<<endl;
	cout<<" ..▎[] ▎田 田 ▎ |┃◆  .      *  $◢■■◣$  * "<<endl;
	cout<<" &&▎  ▎    ▎'|'▎ @    赵伟 * $◢■■■◣$ *  "<<endl;
	cout<<"# ■■■■■■■■■■〓▄▃▂▁08软件8班   ︸︸||︸︸     "<<endl;
	cout<<"                               20052110010810               "<<endl;
	cout<<"………………………………………………………………………………"<<endl;
}
void select()
{
	cout<<"                                   \\\\\\\|///   "<<endl;
    cout<<"                                 \\\\  - -  //   "<<endl;
    cout<<"                                  (  @ @  )      "<<endl;
	cout<<"┏━━━━━━━━━━━━━━━oOOo-(_)-oOOo━┓"<<endl;
	cout<<"┃1.创建 2.添加 3.查找 4.借书并登记 5.还书     ┃"<<endl;
	cout<<"┃                                             ┃"<<endl;
	cout<<"┃6.清除 7.查看总库 8.查看借阅表 9.退出 Oooo   ┃"<<endl;
	cout<<"┗━━━━━━━━━━━━━━━ oooO━-(   )━┛"<<endl;
	cout<<"                                 (   )   ) /     "<<endl;
	cout<<"                                  \\\ (  (_/     "<<endl;
	cout<<"                                    \_)          "<<endl;
}
int creat(ku k[])//创建
{
	int n,i,m=0,j=1;
	book *p;
	cout<<"请输入一共有多少个种类:"<<endl;
	cin>>n;
	for(i=0;i<n;i++)
	{
		j=0;
		cout<<"请输入第 "<<i+1<<"类书的类名称"<<endl;
		cin>>k[i].name;
		k[i].first=0;
		cout<<"请输入在第 "<<i+1<<"本书的书号  以 -1 结尾"<<endl;
		cin>>m;
		while(m!=-1)
		{
			if(!j) 
			{
				p=new book;   
				k[i].first=p;
				p->num=m;
				j++;
			}
			else
			{
				p->next=new book;
				p=p->next;
				p->num=m;
				j++;
			}
			cout<<"请输入第 "<<j<<" 本书的名称 "<<endl;
			cin>>p->name;
			cout<<"请输入第 "<<j<<" 本书的作者 "<<endl;
			cin>>p->author;
			cout<<"请输入第 "<<j<<" 本书的总库总量 "<<endl;
			cin>>p->count;
			p->stock=p->count;
			cout<<"请输入在第 "<<j<<"本的书号  以 -1 结尾"<<endl;
			cin>>m;
		}
		if(k[i].first)
			p->next=0;
	}
	return n;
}
void insert(ku k[],int &n)//添加
{
	int i,j,num;
	string name;
	book *p,*q;
	cout<<"请输入将要添加书籍的类名: "<<endl;
	cin>>name;
	for(i=0;i<n;i++)
		if(name==k[i].name)
			break;
		if(i==n)
		{
			k[i].name=name;
			p=new book;
			k[i].first=p;
			cout<<"请输入所要添加书籍的书号"<<endl;
			cin>>p->num;
			cout<<"请输入所要添加书籍的名称"<<endl;
			cin>>p->name;
			cout<<"请输入所要添加书籍的作者"<<endl;
			cin>>p->author;
			cout<<"请输入所要添加书籍的库存总量"<<endl;
			cin>>p->count;
			p->stock=p->count;
			p->next=0;
			n++;
		}
		else
		{
			book *r;
			p=k[i].first;
			r=p;
			q=new book;
			cout<<"请输入所要添加书籍的书号"<<endl;
			cin>>num;
			while((p)&&(p->num!=num))
			{
				r=p;p=p->next;
			}
			if(!p)
			{
				q=new book;
				q->num=num;
				cout<<"请输入所要添加书籍的名称"<<endl;
				cin>>q->name;
				cout<<"请输入所要添加书籍的作者"<<endl;
				cin>>q->author;
				cout<<"请输入所要添加书籍的库存总量"<<endl;
				cin>>q->count;
				q->stock=q->count;
				q->next=0;	
				r->next=q;
			}
			else
			{
				cout<<"您要添加的书籍名称为 "<<p->name<<" 请输入要添加的数量 "<<endl;
				cin>>j;
				p->count=p->count+j;
				p->stock=p->stock+j;
			}
		}
}
void search_num(ku k[],int n)//按书号查找
{
	int i,j;
	book *p;
	cout<<"请输入要查询的书号"<<endl;
	cin>>j;
	for(i=0;i<n;i++)
	{
		p=k[i].first;
		while(p)
		{
			if(p->num==j)
			{
				cout<<"书号:";
				cout<<p->num;
				cout<<"  书名:";
				cout<<p->name;
				cout<<"  作者:";
				cout<<p->author;
				cout<<"  现存量:";
				cout<<p->stock;
				cout<<"  总库存量:";
				cout<<p->count<<endl;
				return;
			}
			p=p->next;
		}
	}
	if(i==n)
		cout<<"对不起,库中没有您要找的书籍!"<<endl;
}
void search_name(ku k[],int n)//按书名查找
{
	int i;
	string j;
	book *p;
	cout<<"请输入要查询的书名"<<endl;
	cin>>j;
	for(i=0;i<n;i++)
	{
		p=k[i].first;
		while(p)
		{
			if(p->name==j)
			{
				cout<<"书号:";
				cout<<p->num;
				cout<<"  书名:";
				cout<<p->name;
				cout<<"  作者:";
				cout<<p->author;
				cout<<"  现存量:";
				cout<<p->stock;
				cout<<"  总库存量:";
				cout<<p->count<<endl;
				return;
			}
			p=p->next;
		}
	}
	if(i==n)
		cout<<"对不起,库中没有您要找的书籍!"<<endl;
}
void search_author(ku k[],int n)//按作者查找
{
	int i;
	string j;
	book *p;
	cout<<"请输入要查询的书的作者"<<endl;
	cin>>j;
	for(i=0;i<n;i++)
	{
		p=k[i].first;
		while(p)
		{
			if(p->author==j)
			{
				cout<<"书号:";
				cout<<p->num;
				cout<<"  书名:";
				cout<<p->name;
				cout<<"  作者:";
				cout<<p->author;
				cout<<"  现存量:";
				cout<<p->stock;
				cout<<"  总库存量:";
				cout<<p->count<<endl;
				return;
			}
			p=p->next;
		}
	}
	if(i==n)
		cout<<"对不起,库中没有您要找的书籍!"<<endl;
}
void search(ku k[],int n)//查找
{
	char i;
	cout<<"1.按书号查找   2.按书名查找   3.按作者查找  "<<endl;
	cin>>i;
	switch(i)
	{
	case'1':search_num(k,n);break;
	case'2':search_name(k,n);break;
	case'3':search_author(k,n);break;
	default:cout<<"您输入错误!"<<endl;
	}
}
void operat(ku k[],regist *h,int n)//借书并登记
{
	int i,j;
	char c;
	search(k,n);
	book *p;
	cout<<"请输入你要借阅的书籍的书号"<<endl;
	cin>>j;
	for(i=0;i<n;i++)
	{
		p=k[i].first;
		while(p)
		{
			if(p->num==j)
			{
				cout<<"你确定要借这本书吗?y/n"<<endl;
				cin>>c;
				if(c=='y')
				{
					p->stock--;
					goto reg;
				}
				else return;	
			}
			p=p->next;
		}
	}
	if(i==n)
		cout<<"对不起,库中没有您要找的书籍!"<<endl;
	return;
reg:
		regist *r,*q;
		r=h;
		while(r->next)
			r=r->next;
		q=new regist;
		cout<<"请输入您的姓名"<<endl;
		cin>>q->name;
		cout<<"请输入您的学生证号"<<endl;
		cin>>q->no;
		q->bookname=p->name;
		q->enddata="2007年01月19日";
		q->next=0;
		r->next=q;
}
void ret(ku k[],regist *h,int n)//还书
{
	int num;
	int i;
	book *p;
	string name;
	cout<<"请输入您要归还书籍的书号"<<endl;
	cin>>num;
	for(i=0;i<n;i++)
	{
		p=k[i].first;
		while(p)
		{
			if(p->num==num)
			{
				p->stock=p->stock+1;
				goto erase;
			}
			p=p->next;
		}
	}
	if(i==n)
		cout<<"对不起,库中没有您要找的书籍!"<<endl;
erase:
	regist *r,*q;
	r=h;
	cout<<"请输入您的姓名"<<endl;
	cin>>name;
	q=r;//q为前驱
	r=r->next;
	while(r)
	{
			if(r->name==name&&r->bookname==p->name)
			{
				q->next=q->next->next;
				return;
			}
			q=r;
			r=r->next;
	}
	if(!r)
		cout<<"书号与借阅人姓名不符!"<<endl;
}
void clear(ku k[],int &n)//清空
{
	char c;
	int i,j,m;
	book *p,*r;
	cout<<"请问您是要删除整个类(1)  还是要删除某一本书(2)?"<<endl;
	cin>>c;
	if(c=='1')
		goto cll;
	cout<<"请输入您要删除的书号"<<endl;
	cin>>m;
	for(i=0;i<n;i++)
	{
		if(k[i].first->num==m)
		{
			k[i].first=k[i].first->next;
			return;
		}
		p=k[i].first;
		r=p;
		while(p&&(p->num!=m))
		{
			r=p;
			p=p->next;
		}
		if(p&&p->num==m)
		{
			r->next=r->next->next;
			return;
		}
	}
		cout<<"没找到您要删除的书籍"<<endl;
	if(i==n)
	return;
cll:
	for(i=0;i<n;i++)
		cout<<i<<"."<<k[i].name<<"   ";
	cout<<endl;
	cout<<"请输入你要删除的类的代号"<<endl;
	cin>>m;
	while(m<(n-1))
	{
		k[m].name=k[m+1].name;
		k[m].first=k[m+1].first;
		m++;
	}
	n--;
}
void putout_book(ku k[],int n)//总书库输出
{
	
	int i,j;
	book *p;
	cout<<endl;
	cout<<"序号  书号       书名         作者   现存量 总库存量"<<endl;
	for(i=0;i<n;i++)
	{
		j=1;
		cout<<k[i].name<<"_类"<<endl;
		p=k[i].first;
		while(p)
		{
			cout<<j<<setw(7)<<p->num<<setw(15)<<p->name<<setw(12)<<p->author<<setw(7)<<p->stock<<setw(7)<<p->count<<endl;
			p=p->next;
			j++;
		}
	}
}
void putout_reg(regist *h)//借阅情况输出
{ 
	int i=1;
	h=h->next;
	cout<<endl;
	while(h)
	{
       cout<<i++<<" 借阅者姓名: "<<h->name;
	   cout<<" 借阅者学号: "<<h->no;
	   cout<<" 所借书籍名称: "<<h->bookname;
	   cout<<" 最晚归还日期: "<<h->enddata<<endl;
	   h=h->next;
	}
}
void main()
{
	char c,t;
	ku v[5];
	regist *g;
	g=new regist;
	g->next=0;
	int n;
	logo();
again:	select();
	cin>>c;
	switch(c)
	{
	case'1':n=creat(v);break;
	case'2':insert(v,n);break;
	case'3':search(v,n);break;
	case'4':operat(v,g,n);break;
	case'5':ret(v,g,n);break;
	case'6':clear(v,n);break;
	case'7':putout_book(v,n);break;
	case'8':putout_reg(g);break;
	case'9':goto exit;break;
	}	
	cout<<"您要继续操作吗?y/n"<<endl;
	cin>>t;
	if(t=='y')
		goto again;
exit:
	cout<<"             十分感谢您使用本软件  "<<endl;
	cout<<"           有您的支持我们会做的更好"<<endl;
}

⌨️ 快捷键说明

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