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请输入您所还