课程设计——图书管理系统

library.h
#ifndef LIBRARY_INCLUDE
#define LIBRARY_INCLUDE

#include<stdio.h>
#include<string.h>
#include<conio.h>

#include<windows.h>
#include<time.h>

typedef struct BOOK{
	long number;
	char name[30];
	char author[30];
	char press[30];
	long presstime;
	int exist;
	int total;
	struct BOOK *next;
}book;

typedef struct KEY{
	long key;
	book *adress;
	struct KEY *next;
}keynode;

typedef struct READER{
	long number;
	char name[15];
	char sex;
	char password[16];
	int residue;
	long borrowed[10][2];
	int limit;
	struct READER *next;
}reader;
char *lc(int i);
char *sc(char p);
void showR(reader *tr,book *bhead);
void showB(book *p);
book *S_name(book *head,char name[]);
void S_author(book *head);
keynode *initindex(book *head);
void delkey(keynode *keyhead);
book *S_number(long num,book *bhead);
reader *S_reader(reader *rhead,long num);
book *Bload();
reader *Rload();
void Bsave(book *Bhead);
void Rsave(reader *Rhead,book *bhead);
void insert(book *bhead);
void reg(reader *head);
reader *login(reader *rhead,book *bhead);
void borrow(reader *temp,book *Bhead);
void returnbook(book *bhead,reader *temp);
void style();
void intpsd(char *psd);
void menu(struct BOOK *Bhead,reader *Rhead);
void menu2(reader *temp,reader *rhead,book *bhead);
long backtime();
#endif

borrow_return.cpp
#include"library.h"
void borrow(reader *temp,book *Bhead)
{
	style();
	long num;
	int i;
	char t,k,name[30];
	book *Bbook;
	getch();
	system("cls");
	while(1)
	{
		printf("\n                        ┏━━━━━━━━━━┓                        ");
		printf("\n█━━━━━━━━━━━┫借书                ┣━━━━━━━━━━━█");
		printf("\n                        ┗━━━━━━━━━━┛                        ");
		printf("\n请输入您要查找借阅书籍的方式:");
		printf("\n                           1、按书号查找\n");
		printf("\n                           2、按作者查找\n");
		printf("\n                           3、按书名查找\n");
		printf("\n                           4、返回主菜单\n");
		t=getch();
		switch(t)
		{
		case '1':
		{
			printf("\n请输入您要查找的书籍编号:");
			scanf("%d",&num);
			if((Bbook=S_number(num,Bhead))!=NULL)
			{
				showB(Bbook);
				printf("\n请问你是否要借阅该书籍?Y/N");
				k=getch();
				if(k=='Y'||k=='y')
					goto borrow;
				else
					break;
			}
			else
				break;
		}
		case '2':
		{
			S_author(Bhead);
			break;
		}
		case '3':
		{
			printf("\n请输如您要查找的书籍名:");
			scanf("%s",name);
			if((Bbook=S_name(Bhead,name))!=NULL)
			{
				showB(Bbook);
				printf("\n请问你是否要借阅该书籍?Y/N");
				k=getch();
				if(k=='Y'||k=='y')
					goto borrow;
				else
					break;
			}
			else
				continue;
			break;
		}
		default:
			return;

borrow:	if(Bbook!=NULL&&temp->residue>0&&Bbook->exist>0)
		{
			temp->residue--;
			Bbook->exist--;
			for(i=0;i<10;i++)
			{
				if(temp->borrowed[i][0]==0)
				{
					temp->borrowed[i][0]=Bbook->number;
					temp->borrowed[i][1]=backtime();
					break;
				}
			}
			printf("\n                       借阅成功!");
		}
		else
			if(!(temp->residue>0))
				printf("\n您只能借阅10本书籍!");
			else
				if(!(Bbook->exist>0))
					printf("\n该书没有库存,请借阅其他书籍!");

		printf("\n您要继续借阅书籍吗?Y/N");
		t=getch();
		if(t=='y'||t=='Y')
			continue;
		else
		break;
		}
	}
}


void returnbook(book *bhead,reader *temp)
{
	long num;
	int i,j=0;
	char t;
	book *p;
	printf("\n                        ┏━━━━━━━━━━┓                        ");
	printf("\n█━━━━━━━━━━━┫还书                ┣━━━━━━━━━━━█");
	printf("\n                        ┗━━━━━━━━━━┛                        ");
	printf("\n\n请输入您所还
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值