图书馆管理系统(Library management system).doc

上传人:scccc 文档编号:11228590 上传时间:2021-07-15 格式:DOC 页数:42 大小:28.33KB
返回 下载 相关 举报
图书馆管理系统(Library management system).doc_第1页
第1页 / 共42页
图书馆管理系统(Library management system).doc_第2页
第2页 / 共42页
图书馆管理系统(Library management system).doc_第3页
第3页 / 共42页
图书馆管理系统(Library management system).doc_第4页
第4页 / 共42页
图书馆管理系统(Library management system).doc_第5页
第5页 / 共42页
点击查看更多>>
资源描述

《图书馆管理系统(Library management system).doc》由会员分享,可在线阅读,更多相关《图书馆管理系统(Library management system).doc(42页珍藏版)》请在三一文库上搜索。

1、图书馆管理系统(Library management system)#包括#包括字符串。”#包括程序。”#包括。H#定义马克斯3typedef struct的书焦book_num 10 ;/图书编号焦book_name 20 ;/图书名称焦book_writer 10 ;/作者国际book_zonggong_;/ /总共册数国际book_zaiguan_;/ /在馆册数下一本书; BK;typedef struct借焦borrow_book_num 10 ;焦huanshu_date 8 ; BW;typedef struct的读者焦reader_num 10 ;焦reader_name 10

2、 ;国际zuida;BW借用最大;下一个读取器结构;路;* h_book BK;路* 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();/ * * /加载读者信息无效l

3、oad_book();无效modify_booklist();无效show_allbook();无效show_reader();无效delete_book();无效()/ * * /初始化 printf(“* n”);printf(“n本系统第一次使用需要对图书信息和读写信息进行初始化n”);init_reader();init_book();无效init_reader() / * * /注册读者信息路* P0;int i;printf(“n现在请对读写信息进行注册n”);P0 =(RD *)malloc(sizeof(RD);h_reader = P0;printf(“请输入读者的信息:n”

4、);printf(“读者图书证号:”);scanf(“%s”,P0 - reader_num);printf(“读者姓名:”);scanf(“%s”,P0 - reader_name);P0 - zuida = 0;为(i = 0;i 借我。borrow_book_num,“0”);/*所借图书直接置为0(即没有借书)* /strcpy(P0 -借我。huanshu_date,“0”);P0 -下= null;printf(“n注册完毕!按任意键继续下一步操作. n”);printf(“* n”);getch();无效init_book() / * * /初始化图书信息BKP =(BK *)m

5、alloc(sizeof(BK);焦的我;printf(“n现在请对读写信息进行初始化n”);h_book = P;printf(“请输入图书信息:n”);做BKP0 =(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_);

6、P0-book_zaiguan_=p0-book_zonggong_; / * start in the Museum Library and the total number of equal volumes.P0-next=NULL;Printf (whether to continue input? (y/n) n);Scanf (%s, &i);/p0=p0-next;while (i=y);Printf (n initialization is completed! Press any key to continue the next operation! n);Printf (*n

7、);Getch ();System (CLS);Void (Save) / * * / save informationSave_Reader ();Save_Book ();Void (Save_Reader) / * * / save the reader informationFILE *fp_reader; / * * / create a file pointerRD *p, *p0;P=h_reader;If (fp_reader=fopen (Reader.txt, WB) =NULL) / * create a file, save.Printf (n file failed

8、to save! n, please restart this system. n);Exit (0);While (P! =NULL)If (fwrite (P, sizeof (RD), 1, fp_reader) =1 / *!) readers in the list information written to the file.Printf (n write file failed! n, please restart this system! n);P0=p;P=p-next;Free (P0); / * * / release of all nodesH_reader=NULL

9、;Fclose (fp_reader); / * * / close the fileVoid (Save_Book) / * * / save the book informationFILE *fp_book; / * * / create a file pointerBK *p, *p0;P=h_book;If (fp_book=fopen (Book.txt, WB) =NULL) / * create a file, save.Printf (n file failed to save! n, please restart this system. n);Exit (0);While

10、 (P! =NULL)If (fwrite (P, sizeof (BK), 1, fp_book) =1 / *!) will list the information written to the file.Printf (n write file failed! n, please restart this system! n);P0=p;P=p-next;Free (P0);H_book=NULL;Fclose (fp_book);Void (Load) / * * / loading the reader information and Book InformationLoad_Re

11、ader ();Load_Book ();Void (Load_Reader) / * * / loading the reader informationRD *p1, *p2, *p3;FILE *fp; / * * / create a file pointerFp=fopen (Reader.txt, RB); / * * / open fileP1= (RD *) malloc (sizeof (RD);FREAD (P1, sizeof (RD), 1, FP);H_reader=p3=p2=p1;While (! Feof (FP) / * read the reader inf

12、ormation, Re Chain into the list.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); / * * / close the fileVoid (Load_Book) / * * / loading of book informationBK *p1, *p2, *p3;FILE *fp; / * * / create a file pointerFp=fopen (Book.t

13、xt, RB); / * * / open fileP1= (BK *) malloc (sizeof (BK);FREAD (P1, sizeof (BK), 1, FP);H_book=p3=p2=p1;While (! Feof (FP) / * read information, Re Chain into the list.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); / * * / clo

14、se the file无效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)= = 0)/ *此处分两种情况,若图书编号存在,则直接入库,

15、只须输入图书的数量*/printf(“n不你好,此编号的图书已存在,直接入库!“n);printf(“不图书数量:”);scanf(“%d”,与P1 - book_zonggong_);book_zonggong_ + = P1 P2 - - book_zonggong_;book_zaiguan_ + = P1 P2 - - book_zonggong_;/ * * /开始时图书在馆册数和总共册数相等其他/ *若图书编号不存在,则需要输入图书的所有信息,然后再进行插入操作*/printf(“不图书名称:”);scanf(“%s”,P1 - book_name);printf(“不图书作者:”

16、);scanf(“%s”,P1 - book_writer);printf(“不图书数量:”);scanf(“%d”,与P1 - book_zonggong_);同时(p下)下一页;如果(h_book = = null)h_book = P1;/*此处分两种情况,链表中没有数据,头头指针直接指向P1处*/其他的P - 下= P1;/*链表中有数据,链表中最后元素的下指向P1处*/P1 =下一个null;book_zaiguan_ = P1 P1 - - book_zonggong_;printf(“n不新书入库完毕!按任意键继续下一步操作. n”);printf(“不- n”);getch()

17、;系统(“CLS”);无效delete_book() /删除 BKP = h_book -下一步,*q = h_book;字符名称 10 ;如果(P!= null)printf(“请输入要删除的书名:”);scanf(“%s”,与名);而(P!= null & strcmp(Pbook_name,姓名)!= 0)q = P;下一页;如果(P!= null)/如果P此时不是最后一个节点,说明此时已经找到书下一步;printf(“删除成功!按任意键继续下一步操作. n”);printf(“不- n”);getch();系统(“CLS”);如果(P = = null)/如果P此时为最后一个结点并且没

18、有找到与之相符的书名printf(“你输入的书名不存在,请核实后重新输入!“n);无效select_book() / * * /查找图书信息BK病毒;int c;焦book_num 10 ,book_name 20 ,book_writer 10 ;P = h_book;printf(“T1按书号查询:n”);printf(“T2按书名查询:n”);printf(“T3按作者名查询:n”);printf(“不请选择相应的操作(1-4):”);scanf(“%d”,& C);如果(C3 | | C1)printf(“不您的输入有误!”);scanf(“%d”,& C);开关(c)案例1:prin

19、tf(“n不请输入你要查询的图书编号:”);scanf(“%s”,book_num);而(strcmp(Pbook_num,book_num)!= 0和p下一步)下一行;如果(strcmp(Pbook_num,book_num)= = 0)printf(“n不图书编号%s的信息为:n”,book_num);printf(“不图书编号图书名称图书作者在馆册数总共册数n”);printf(“t %s %s %s T T T %d %dn”,Pbook_num,Pbook_name,Pbook_writer,Pbook_zaiguan_,Pbook_zonggong_);其他的printf(“n不此

20、图书不存在,请核对!”);printf(“n不新书入库完毕!按任意键继续下一步操作. n”);printf(“不- n”);getch();系统(“CLS”);打破;案例2:printf(“n不请输入你要查询的图书名称:”);scanf(“%s”,book_name);而(strcmp(Pbook_name,book_name)!= 0和p下一步)下一行;如果(strcmp(Pbook_name,book_name)= = 0)printf(“n不图书名称%s的信息为:n”,book_name);printf(“不图书编号图书名称图书作者在馆册数总共册数n”);printf(“t %s %s

21、%s T T T %d %dn”,Pbook_num,Pbook_name,Pbook_writer,Pbook_zaiguan_,Pbook_zonggong_);其他的printf(“n不此图书不存在,请核对!”);printf(“n不新书入库完毕!按任意键继续下一步操作. n”);printf(“不- n”);getch();系统(“CLS”);打破;案例3:printf(“n不请输入你要查询图书的作者:”);scanf(“%s”,book_writer);而(strcmp(Pbook_writer,book_writer)!= 0和p下一步)下一行;如果(strcmp(Pbook_wr

22、iter,book_writer)= = 0)printf(“n不图书名称%s的信息为:n”,book_writer);printf(“不图书编号图书名称图书作者在馆册数总共册数n”);printf(“t %s %s %s T T T %d %dn”,Pbook_num,Pbook_name,Pbook_writer,Pbook_zaiguan_,Pbook_zonggong_);其他的printf(“n不此图书不存在,请核对!”);printf(“n不新书入库完毕!按任意键继续下一步操作. n”);printf(“不- n”);getch();系统(“CLS”);打破;无效modify_bo

23、ok()BK病毒;/;P = h_book;焦book_num 10 ;printf(“n不请输入你要修改的图书编号:”);scanf(“%s”,book_num);而(strcmp(Pbook_num,book_num)!= 0和p下一步)下一行;如果(strcmp(Pbook_num,book_num)= = 0)printf(“不请输入修改后的信息!“n);printf(“n”);printf(“不图书编号图书名称图书作者在馆册数总共册数n”);scanf(“%s %s T T T T %d %s T %d”,普- book_num,普- book_name,普- book_writer

24、,普- book_zaiguan_,普- book_zonggong_);printf(“n不修改成功!按任意键继续下一步操作. n”);printf(“不- n”);getch();其他的printf(“不此编号的图书不存在”);无效borrow_book()BK;焦bo_num 20 ,reader_num 20 ,huan_date 8 ;int i;P1 = h_book;P2 = h_reader;printf(“n不借书INGn”);printf(“n不请输入借书的读者图书证号:”);scanf(“%s”,reader_num);当(下一个)!= null & strcmp(rea

25、der_num,P2 - reader_num)!= 0)/ * * /遍历一次读者链表,判断读者是否存在下一步;如果(P2 -下= = null & strcmp(reader_num,P2 - reader_num)!= 0)/ *如果存在,则继续,不存在就提示错误!* /printf(“n不不好意思,此读者图书证号不存在!按任意键返回n”);去结束;其他的printf(“n不请输入你所借图书的编号:”);scanf(“%s”,bo_num);而(strcmp(bo_num,P1 - book_num)!= 0和下一步!= null)/ * * /遍历一次图书链表,判断此图书是否存在下一步

26、;如果(P1 -下= = null & strcmp(bo_num,P1 - book_num)!= 0)/ *如果存在,则继续,不存在就提示错误!* /printf(“n不不好意思,此图书编号不存在!按任意键返回n”);如果(P1 - book_zaiguan_ zuida =马克斯)/ * * /判断此读者借书权限是否已达最大printf(“n不不好意思,借书数目已满!不能借书!按任意键返回的”);如果(strcmp(P2 -借 0 。borrow_book_num,“0”)!= 0)/ * * /此读者若已经借书,再判断此读者是否要借两本一样的书为(i = 0;i 借我。borrow_b

27、ook_num,bo_num)= = 0)printf(“n不不好意思,!同一个读者不能同借两本相同的书!“n);如果(strcmp(P2 -借我。borrow_book_num,”0“)= = 0)/ * * /如果没有重复,则继续printf(“n不请输入你要归还图书的日期例如(2001-02-21):”);scanf(“%s”,huan_date);strcpy(P2 -借 P2 - zuida + 。borrow_book_num,bo_num);/*记录读者所借图书书号,并且借书数目加一,现存量减一*/strcpy(P2 -借 P2 - zuida-1 。huanshu_date,h

28、uan_date);P1 - book_zaiguan_ -;printf(“n不读者编号%s借书完毕!按任意键继续下步操作.”,P2 - reader_num);突破;其他若此读者从未借过书/ * * /printf(“n不请输入你要归还图书的日期例如(2001-02-21):”);scanf(“%s”,huan_date);strcpy(P2 -借 P2 - zuida + 。borrow_book_num,bo_num);/*记录所借书号,并且借书数目加一,现存量减一*/strcpy(P2 -借 P2 - zuida-1 。huanshu_date,huan_date);P1 - boo

29、k_zaiguan_ -;printf(“n不读者编号%s借书完毕!按任意键继续下步操作.”,P2 - reader_num);结束:getch();系统(“华彩”);无效return_book()BK;int,j,查找= 0;焦return_book_num 10 ,return_reader_num 10 ;P = h_book;Q = h_reader;printf(“n不还书INGn”);printf(“n不请输入要还书的读者图书证号:”);scanf(“%s”,return_reader_num);当(下一个)!= null & strcmp(return_reader_num,Qr

30、eader_num)!= 0)下一个;如果(Q = = null & 下strcmp(return_reader_num,Qreader_num)!= 0)发现= 2;/*用于设置标志,判断读者是否借了此书或是否不满足某一条而提前出错结束,若提前出错,则发现= 2,若借了此图书,则发现= 1,若没借此书则发现= 0,以下设置雷同*/printf(“n此读者编号不存在!按任意键返回. n”);去结束;printf(“n不请输入您归还图书的编号:”);scanf(“%s”,return_book_num);同时(P下一步)!= null & strcmp(return_book_num,Pbook

31、_num)!= 0)下一页;如果(P 下= = null & strcmp(return_book_num,Pbook_num)!= 0)查找= 2;printf(“n不错误!此图书编号不存在!按任意键返回. n”);去结束;为(i = 0;i 马克斯;我+ +)如果(strcmp(return_book_num,Q借我。borrow_book_num)= = 0)查找= 1;为(J =我;J book_zaiguan_ + +;问:zuida -;printf(“n不编号%s的读者还书完毕!按任意键继续下步操作.”,return_reader_num);如果(查找= 0)printf(“n不

32、错误!此读者未借此书!按任意键返回. n”);结束:getch();系统(“华彩”);无效show_allbook()BK病毒;P = h_book -下;printf(“n不图书信息如下:n n”);printf(“不图书编号图书名称图书作者在馆册数总共册数n”);/*直接显示所有图书的信息,遍历图书链表一次就可以了*/而(P!= null)printf(“t %s %s %s T T T %d %dn”,Pbook_num,Pbook_name,Pbook_writer,P book_zaiguan_,Pbook_zonggong_);下一页;printf(“n不图书显示完毕!按任意键继续

33、下一步操作”。);printf(“n不- n”);getch();/系统(“CLS”);无效show_reader()RD;int i;P = h_reader;printf(“n读者信息如下:n n”);printf(“读者图书证号不读者姓名”);printf(“n”);而(P!= null)/遍历一次读者链表就可以了printf(“%s T/T %s”,Preader_num,Preader_name);为(i = 0;i 8)printf(“n不错误!请重新输入:”);别人休息;还我;无效menu_select_book() /主菜单选择为(;)/循环调用模式,保证能进行重复操作开关(m

34、enu())/功能选择案例0:系统(“CLS”);save();Printf (nnnnnnnnnntttt, thank you for your use!);Getch ();Exit (0);Case 1:Insert_New_Book ();Break;Case 2:Delete_Book ();Break;Case 3:Borrow_Book ();Break;Case 4:Return_Book ();Break;Case 5:Modify_book ();Break;Case 6:Select_book ();Break;Case 7:Show_Allbook ();Break;Case 8:Show_reader ();Break;Default:Printf (nt error! Please re input:!);Exit (0);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1