图书管理系统(C++)

这是一个采用C++编程语言开发的全面的图书管理系统,详细介绍了其功能和实现过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个项目还是很完善的,也建议看看。

#include <stdlib.h>
#include <iostream>
#include <conio.h>
#include <string.h>
#define MAXREADER 20
using namespace std;

struct Date					/*日期结构*/
{ 
	int Year;				/*年*/
    int Month;				/*月*/    
    int Day;				/*日*/   
};

struct Reader				/*读者结构*/
{
	char num[20];			/*借书证号*/
	struct Date bro;		/*借出时间*/     
	struct Date back;       /*归还时间*/        
};

struct  Book                /*图书结构*/
{
	int  BookNumber;        /*对应书号*/           
	char strTitle[150];     /*书名*/
	char strWroter[150];    /*作者*/   
	int  RemNum;            /*可借阅册数*/    
	int  AllNum;			/*馆藏总册数*/      
	char strComment[300];   /*图书简介*/   
	struct Reader reader[MAXREADER]; 
};

struct Info                 /*借书信息结构*/
{
	struct Info *pParentPoint; /*前驱结点*/      
	struct Book *pBookInfo;    /*对应图书的信息*/    
	struct Info *pSon;         /*后继结点*/
};

struct Book *InputNode();
struct Info *Search(struct Info *bth,int x,int *flag);	/*查找图书*/
struct Info *InsertBookInfo(struct Info *bth);/*增加图书*/
struct Info *DeleteBookInfo(struct Info *bth);/*删除图书*/
void   OutputBookInfo(struct Info *bth);/*输出图书信息*/
void   BorrowBook(struct Info *bth);/*图书借阅*/
void   ReturnBook(struct Info *bth);/*图书归还*/
void SaveInfo(struct Info *head);/*保存图书信息*/
struct Info *ReadInfo();/*读取图书信息*/
char   ListMenu();/*图书馆管理系统主菜单*/

struct Info *Search(struct Info *head,int x,int *flag)
{
	struct Info *p=NULL;
	p=head; /*每次查询前,将工作指针指向双向链表头部结点*/
	*flag=0; /*是否查找到指定书号的标志*/
	while(p)
	{
		if(p->pBookInfo->BookNumber==x)
		{
			*flag = 1;/*找到相同的书号,置找到的标志*/
			return p;
		}
		if(p->pSon!=NULL)
			p = p->pSon;/*没到双向链表的尾部时,向后移动当前指针*/
		else
			break;/*到达链表尾部,跳出循环*/
	}
	return head;
}

struct Book *InputNode()
{
	struct Book *p=NULL;
	int i;
	
	p=(struct Book *)malloc(sizeof(struct Book));   /*分配内存*/
	fflush(stdin);  /*清除以前的输入*/
	cout << endl;
	cout << "请输入书名:";   
	cin >> p->strTitle;/*从键盘取得书名*/
	cout << endl;
	cout << "请输入作者:";   	
	cin >> p->strWroter;/*从键盘取得作者名*/
	cout << endl;
	cout << "请输入可借阅册数:";   	
	cin >> p->RemNum;/*从键盘取得当前可借阅册数*/
	cout << endl;
	cout << "请输入馆藏总册数:";   
	cin >> p->AllNum;/*从键盘取得当前馆藏总册数*/
	fflush(stdin);
	cout << endl;
	cout << "请输入本书简介:";   
	cin >> p->strComment;
	/*初始化图书结构成员的相关读者指针内容为空*/
	for(i=0;i<MAXREADER;i++)
		(p->reader[i]).num[0]='\0';	
	return p;  /*返回成功插入的一本书信息*/
}

struct Info *InsertBookInfo(struct Info *head)
{
	int flag;
	int x,z;
	struct Info *p=NULL,*q=NULL;
	struct Book *bookinfo=NULL;
	cout << endl;
	cout << "请输入增加的书号:";   
	cin >> x;	
	q=Search(head,x,&flag);/*查找借阅的书是否有馆藏*/
	if(flag==1)   
    {
		/*查找成功,存在此书*/
		cout << endl;
		cout << "当前馆藏<<" << q->pBookInfo->strTitle << ">>书共有" << q->pBookInfo->AllNum << "本,您想新增一本吗?(y/n)" << endl;
		z=getch();
		if(z=='y'||z=='Y')       
		{
			q->pBookInfo->AllNum++;
			q->pBookInfo-
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值