当前位置:网站首页>2022.2.27 library management system 3 - book borrowing and returning registration module
2022.2.27 library management system 3 - book borrowing and returning registration module
2022-06-11 13:46:00 【Warm old D】
This is the third module of the library management system , There are some details to pay attention to
In the book borrowing registration system , Pay attention to when books exist , When books don't exist , The most important thing is to keep the information after borrowing the book , Because all the work done in the code is done in the array , In case something happens , Save it in a file , And every time I borrow a Book , Remember to subtract from the stock of books 1, The current number of readers who can borrow minus 1, In this way, the borrowing procedure will be complete . Return code similar .
// Borrow and return submenu
void ShowBorrowReturnMenu()
{
system("cls");
printf("\n\n\n\n");
printf("\t********************** Welcome to ***********************\n");
printf("\t********************* Registration of borrowing and returning books ***********************\n");
printf("\t********************** Sub menu *************************\n");
printf("\t*********************1. Book borrowing registration ***********************\n");
printf("\t*********************2. Book return registration ***********************\n");
printf("\t*********************0. Back to main menu *********************\n");
printf("\t******************************************************\n");
printf("\n");
printf("\t\t Please select (0-2)");
}
// Borrow books
void BorrowBook()
{
// Whether readers can borrow books
system("cls");
int iBookld, iReaderld, iBorrow, i;//iBorrow The reader borrowed some books
// Enter the number of the reader who wants to borrow the book , Determine whether the number exists , If there is , Display the book information that readers have borrowed
iReaderld = SearchReader();
if (iReaderld == -1)// non-existent
{
return;
}
iBorrow = astReader[iReaderld].iMax - astReader[iReaderld].iAmount;
if (iBorrow == 0)
{
printf(" The reader has not borrowed any books at present ");
}
else
{
printf("\t The reader is currently borrowing :");
for (i = 0; i < iBorrow; i++)
{
printf("%d", astReader[iReaderld].Bookld[i]);// The corresponding subscript in the array is the number of the stored book
}
printf("\n\n");
}
if (astReader[iReaderld].iAmount == 0)
{
printf(" The number of books that this reader can borrow is 0, You can't continue to borrow books \n");
}
// Whether books can be borrowed
printf("\n Press any key to enter the book information to borrow \n");
_getch;
iBookld = SearchBook();
if (iBookld == -1)
{
return;
}
if (astBook[iBookld].iAmount == 0)
{
printf(" The stock of the book is 0! Books cannot be borrowed !\n");
return;
}
// Borrow books
astReader[iReaderld].Bookld[iBorrow] = astBook[iBookld].iNum;
// Inventory of books -1
astBook[iBookld].iAmount--;
// The number of books available to current readers -1
astReader[iReaderld].iAmount--;
// Operation in array , Must be saved in a file
SaveBookFile(iBookld);
SaveReaderFile(iReaderld);
printf(" Borrow books successfully !\n");
}
// Return books
void ReturnBook()
{
system("cls");
int iBookld, iReaderld, iBorrow, i, j;// Whether the reader borrows the book
//1. Is the reader in the system
iReaderld = SearchReader();
if (iReaderld == -1)
{
return;
}
//
iBorrow = astReader[iReaderld].iMax - astReader[iReaderld].iAmount;
if (iBorrow == 0)
{
printf("\t The reader did not borrow any books , No need to return !\n");
return;
}
else
{
printf("\t The books that the reader is currently borrowing are :");
for (i = 0; i < iBorrow; i++)//iBorrow I borrowed some books by myself
{
printf("%d", astReader[iReaderld].Bookld[i]);
}
}
printf(" Press any key to enter the book information to be returned \n");
_getch;
//2. Is the book in the system
iBookld = SearchBook();
if (iBookld == -1)
{
return;
}
//3. Is there this book in the loan list
for (i = 0; i < iBorrow; i++)
{
if (astReader[iReaderld].Bookld[i] == astBook[iBookld].iNum)
{
// If this book is on the loan list , To return the book
for (j = i; j < iBorrow - 1; j++)
{
astReader[iReaderld].Bookld[j] = astReader[iReaderld].Bookld[j + 1];
}
astReader[iReaderld].Bookld[iBorrow - 1] = 0;
// Book inventory plus 1
astBook[iBookld].iAmount++;
// The number of books that readers can borrow
astReader[iReaderld].iAmount++;
break;
}
}
if (i == iBorrow)
{
printf(" The reader did not borrow the book , No need to return !\n");
return;
}
// Return books
SaveBookFile(iBookld);
SaveReaderFile(iReaderld);
printf(" Return the book successfully \n");
}
// Book borrowing and returning module
void BorrowReturnManger()
{
ShowBorrowReturnMenu();// The submenu of borrowing and returning books
int iltem;
scanf("%d", &iltem);
getchar();
while (iltem)
{
switch (iltem)
{
case 1:
BorrowBook();// Borrow books
break;
case 2:
ReturnBook();// Return books
break;
default:
printf("\t\t Please enter the correct number !\n");
}
printf(" Press any key to return to the submenu ");
_getch;
ShowBorrowReturnMenu();// The submenu of borrowing and returning books
scanf("%d", &iltem);
getchar();
}
}
边栏推荐
- SQL:如何用采购单销售单的数据 通过移动加权平均法 计算商品成本
- Kubernetes binary installation (v1.20.15) (VII) plug a work node
- 自定义Terraform-Providers(Terraform Plugin Framework)-04
- create_ Error in engine MySQL connector encryption method
- Why does each running Department display that the database already exists, delete the database, and then succeed? Each running department must delete the database, and re run the whole successfully
- How can tampermonkey replace flash player with H5 player?
- [Multisim Simulation] 555 flash lamp experiment
- On the continuing Life of Distributed Locks - - Distributed Locks Based on redis
- Energy storage operation and configuration analysis of high proportion wind power system (realized by Matlab)
- AGV robot RFID sensor ck-g06a and Siemens 1200plc Application Manual
猜你喜欢

Teatalk · online speech record | complete! It is important to select the right data migration strategy for safe cloud deployment

全球手机市场衰退,连苹果也对iPhone14不抱过高期待

AGV robot RFID sensor ck-g06a and Siemens 1200plc Application Manual

JSP实现银柜台业务绩效考核系统

高比例风电电力系统储能运行及配置分析(Matlab实现)

Variable parameter expression

Introduction to long connection

Container -- reverse content -- use of explosion, splicing, and inversion functions

Some transformation thoughts of programmers after they are 35 years old

Please, don't use enumeration types in external interfaces any more!
随机推荐
Learning notes of yolov3: model structure of yolov3
The end of an era! After ten years, Wu Enda's classic machine learning course closed its registration this month and launched a new course
ecplise无法连接sql server
Unsealing easy QF PDA helps enterprises improve ERP management
tf.data(二) —— 并行化 tf.data.Dataset 生成器
SQL must know and know
create_ Error in engine MySQL connector encryption method
D interval to nullable conversion
[Multisim Simulation] 555 flash lamp experiment
Variable parameter expression
Optimal dispatching (thermal power, wind and energy storage) (realized by Matlab)
JSP实现银柜台业务绩效考核系统
六.开发记录之实验室服务器LXD部署
使用华为HECS云服务器打造Telegraf+Influxdb+Grafana 监控系统【华为云至简致远】
LNMP deployment
2022工具钳工(中级)操作证考试题库及答案
Musk says he doesn't like being a CEO, but rather wants to do technology and design; Wu Enda's "machine learning" course is about to close its registration | geek headlines
On the continuing Life of Distributed Locks - - Distributed Locks Based on redis
AGV robot RFID sensor ck-g06a and Siemens 1200plc Application Manual
[acwing 237. program automatic analysis] parallel search + discretization