图书馆管理系统Library management system.docx
《图书馆管理系统Library management system.docx》由会员分享,可在线阅读,更多相关《图书馆管理系统Library management system.docx(22页珍藏版)》请在冰豆网上搜索。
![图书馆管理系统Library management system.docx](https://file1.bdocx.com/fileroot1/2022-10/29/0cc87461-3824-47a9-b242-9c0c9ade379a/0cc87461-3824-47a9-b242-9c0c9ade379a1.gif)
图书馆管理系统Librarymanagementsystem
图书馆管理系统(Librarymanagementsystem)
#包括
#包括<字符串。
”
#包括<<程序。
”
#包括<是>。
H
#定义马克斯3
typedefstruct的书
{
焦book_num[10];//图书编号
焦book_name[20];//图书名称
焦book_writer[10];//作者
国际book_zonggong_;//总共册数
国际book_zaiguan_;//在馆册数
下一本书;
}BK;
typedefstruct借
{
焦borrow_book_num[10];
焦huanshu_date[8];
}BW;
typedefstruct的读者
{
焦reader_num[10];
焦reader_name[10];
国际zuida;
BW借用[最大];
下一个读取器结构;
}路;
*h_bookBK;
路*h_reader;
国际menu();/**/主菜单
无效menu_select_book();
无效();/*初始化*/
无效init_reader();
无效init_book();
无效insert_new_book();/**/新书入库
无效select_book();
无效borrow_book();
无效return_book();
无效save();/**/保存信息
无效save_reader();
无效save_book();
无效();
无效load_reader();/**/加载读者信息
无效load_book();
无效modify_booklist();
无效show_allbook();
无效show_reader();
无效delete_book();
无效()/**/初始化
{printf(“**************************************************\n”);
printf(“\n本系统第一次使用需要对图书信息和读写信息进行初始化\n”);
init_reader();
init_book();
}
无效init_reader()/**/注册读者信息
{
路*P0;
inti;
printf(“\n现在请对读写信息进行注册\n”);
P0=(RD*)malloc(sizeof(RD));
h_reader=P0;
printf(“请输入读者的信息:
\n”);
printf(“读者图书证号:
”);
scanf(“%s”,P0->reader_num);
printf(“读者姓名:
”);
scanf(“%s”,P0->reader_name);
P0->zuida=0;
为(i=0;i<<马克斯;我++)
{
strcpy(P0->借[我]。
borrow_book_num,“0”);/*所借图书直接置为0(即没有借书)*/
strcpy(P0->借[我]。
huanshu_date,“0”);
}
P0->下=null;
printf(“\n注册完毕!
按任意键继续下一步操作..\n”);
printf(“**************************************************\n”);
getch();
}
无效init_book()/**/初始化图书信息
{
BK×P=(BK*)malloc(sizeof(BK));
焦的我;
printf(“\n现在请对读写信息进行初始化\n”);
h_book=P;
printf(“请输入图书信息:
\n”);
做
{
BK×P0=(BK*)malloc(sizeof(BK));
P>下=P0;
下一页;
printf(“图书编号:
”);
scanf(“%s”,P0->book_num);
printf(“图书名称:
”);
scanf(“%s”,P0->book_name);
printf(“图书作者:
”);
scanf(“%s”,P0->book_writer);
printf(“图书数量:
”);
scanf(“%d”,与P0->book_zonggong_);
P0->book_zaiguan_=p0->book_zonggong_;/*startintheMuseumLibraryandthetotalnumberofequalvolumes.
P0->next=NULL;
Printf("whethertocontinueinput?
(y/n)\n");
Scanf("%s",&i);
//p0=p0->next;
}while(i=='y');
Printf("\ninitializationiscompleted!
Pressanykeytocontinuethenextoperation!
\n");
Printf("**************************************************\n");
Getch();
System("CLS");
}
Void(Save)/**/saveinformation
{
Save_Reader();
Save_Book();
}
Void(Save_Reader)/**/savethereaderinformation
{
FILE*fp_reader;/**/createafilepointer
RD*p,*p0;
P=h_reader;
If((fp_reader=fopen("Reader.txt","WB"))==NULL)/*createafile,save.
{
Printf("\nfilefailedtosave!
\n,pleaserestartthissystem...\n");
Exit(0);
}
While(P!
=NULL)
{
If(fwrite(P,sizeof(RD),1,fp_reader)=1/*!
)readersinthelistinformationwrittentothefile.
Printf("\nwritefilefailed!
\n,pleaserestartthissystem!
\n");
P0=p;
P=p->next;
Free(P0);/**/releaseofallnodes
}
H_reader=NULL;
Fclose(fp_reader);/**/closethefile
}
Void(Save_Book)/**/savethebookinformation
{
FILE*fp_book;/**/createafilepointer
BK*p,*p0;
P=h_book;
If((fp_book=fopen("Book.txt","WB"))==NULL)/*createafile,save.
{
Printf("\nfilefailedtosave!
\n,pleaserestartthissystem...\n");
Exit(0);
}
While(P!
=NULL)
{
If(fwrite(P,sizeof(BK),1,fp_book)=1/*!
)willlisttheinformationwrittentothefile.
Printf("\nwritefilefailed!
\n,pleaserestartthissystem!
\n");
P0=p;
P=p->next;
Free(P0);
}
H_book=NULL;
Fclose(fp_book);
}
Void(Load)/**/loadingthereaderinformationandBookInformation
{
Load_Reader();
Load_Book();
}
Void(Load_Reader)/**/loadingthereaderinformation
{
RD*p1,*p2,*p3;
FILE*fp;/**/createafilepointer
Fp=fopen("Reader.txt","RB");/**/openfile
P1=(RD*)malloc(sizeof(RD));
FREAD(P1,sizeof(RD),1,FP);
H_reader=p3=p2=p1;
While(!
Feof(FP))/*readthereaderinformation,ReChainintothelist.
{p1=(RD*)malloc(sizeof(RD));
FREAD(P1,sizeof(RD),1,FP);
P2->next=p1;
P3=p2;
P2=p1;
}
P3->next=NULL;
Free(P1);
Fclose(FP);/**/closethefile
}
Void(Load_Book)/**/loadingofbookinformation
{
BK*p1,*p2,*p3;
FILE*fp;/**/createafilepointer
Fp=fopen("Book.txt","RB");/**/openfile
P1=(BK*)malloc(sizeof(BK));
FREAD(P1,sizeof(BK),1,FP);
H_book=p3=p2=p1;
While(!
Feof(FP))/*readinformation,ReChainintothelist.
{p1=(BK*)malloc(sizeof(BK));
FREAD(P1,sizeof(BK),1,FP);
P2->next=p1;
P3=p2;
P2=p1;
}
P3->next=NULL;
Free(P1);
Fclose(FP);/**/closethefile
}
无效insert_new_book()/**/新进图书
{
BK*,*P1,*P2;
P=P2=h_book;
printf(“\n不请输入新书信息(包括书号、书名)\n”);
P1=(BK*)malloc(sizeof(BK));
printf(“不图书编号:
”);
scanf(“%s”,P1->book_num);
而(strcmp(P1,P2->->book_num,book_num)!
=0和下一个!
=null)
下一步;
如果(strcmp(P1,P2->->book_num,book_num)==