2022年C语言图书馆信息管理 .pdf

上传人:Che****ry 文档编号:34881343 上传时间:2022-08-19 格式:PDF 页数:16 大小:87.75KB
返回 下载 相关 举报
2022年C语言图书馆信息管理 .pdf_第1页
第1页 / 共16页
2022年C语言图书馆信息管理 .pdf_第2页
第2页 / 共16页
点击查看更多>>
资源描述

《2022年C语言图书馆信息管理 .pdf》由会员分享,可在线阅读,更多相关《2022年C语言图书馆信息管理 .pdf(16页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、#include #include #include using namespace std; class Librarian /图书管理员类 public: Librarian(); Librarian(int n,int j,char na20,int w ); int getnumber(); int getjobage(); char *getname(); int getwages(); void resetjobage(int j); void resetwages(int w); void resetname(char na20); private: int number; in

2、t jobage; char name20; int wages; ; Librarian:Librarian() /其函数的实现 number=0; char b20=no one; jobage=0; strcpy(name,b); Librarian:Librarian(int n,int j,char na20,int w) number=n; jobage=j; strcpy(name,na); wages=w; int Librarian:getjobage() return jobage; char *Librarian:getname() return name; int Li

3、brarian:getnumber() return number; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 16 页 - - - - - - - - - int Librarian:getwages() return wages; void Librarian:resetjobage(int j) jobage=j; void Librarian:resetname(char na20) strcpy(name,na); void Librarian:reset

4、wages(int w) wages=w; class reader /读者类 private: int number; int age; char name20; char borrowbook20; public: reader(); reader(int c,int a,char b20,char e20); int getnumber(); int getage(); char *getname(); char * getborrowbook(); void reworkborrowbook(char a20); ; reader:reader() /其函数的实现 char a20=没

5、有人 ; char c20=没有借书 ; number=0; age=0; reader:reader(int a,int c,char d20,char e20) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 16 页 - - - - - - - - - number=a; age=c; strcpy(name,d); strcpy(borrowbook,e); int reader:getnumber()return number; int reader:getag

6、e()return age; char *reader:getname()return name; char * reader:getborrowbook()return borrowbook; void reader:reworkborrowbook(char a20)strcpy(borrowbook,a); struct book /图书的结构体 int num; char name20; char writer20; ; void outbookinf() /输出所有图书信息 int i; ifstream infile(allbook.txt,ios:in); char line50

7、; cout 书名 t书号 t作者 endl; for(i=1;i=10;i+) infile.getline(line,50,n); coutlinen; file.close(); else cout没有图书管信息理员; exit(0); ifstream is(controlloer.txt,ios_base:binary); if(is) Librarian *A=new Librariann; for(i=0;in;i+) is.read(char *)&Ai,sizeof(Ai); for(i=0;in;i+) cout 编号 t工龄 t名字 t工资 endl; coutAi.ge

8、tnumber()tAi.getjobage()tAi.getname()tAi.getwages()endl; else couttxt文件打开出错 endl; is.close(); void libary() /图书馆的总信息 system(cls); system(color 2e); cout endl; cout endl; cout endl; cout 本校图书馆由本部图书馆及彭州校区图书馆组成,图书馆总面积达了* 平方米 ; cout (本馆现在有* 类书籍 * 万册, * 类书籍 * 万册, * 类书籍 * 万册 *类书籍 * 万册),; cout 图书馆现有工作人员* 名

9、; cout 图书馆现有的现代化设备价值超过* 万元n; file.close(); else n=0; cout 已有的图书管理员个数:; coutnendl; coutnumagenamewage; Librarian A(num,age,name,wage); cout 编号工龄名字工资 endl; coutA.getnumber() A.getjobage() A.getname() A.getwages()endl; ofstream outfile(controlloer.txt,ios_base:app ); outfile.write(char *)&A,sizeof(A);

10、outfile.close(); n+; ofstream tfile(serchLaninf.txt); tfilen; tfile.close(); coutn; file.close(); else cout没有图书管信息理员; exit(0); cout 已有的图书管理员个数:; coutnendl; Librarian *A=new Librariann; ifstream is(controlloer.txt,ios_base:binary); if(is) for(i=0;in;i+) is.read(char *)&Ai,sizeof(Ai); for(i=0;in;i+) 名

11、师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 16 页 - - - - - - - - - cout 编号工龄名字工资endl; coutAi.getnumber() Ai.getjobage() Ai.getname() Ai.getwages()endl; else cout 打开文件出错endl; is.close(); couth; coutjobagenamewage; Ah-1.resetjobage(jobage); Ah-1.resetname(name)

12、; Ah-1.resetwages(wage); cout该管理员修改后的名字是:Ah-1.getname() 工龄是:Ah-1.getjobage() 工资是 :Ah-1.getwages()endl; ofstream tfile(controlloer.txt,ios_base:binary); for(j=0;jn;j+) tfile.write(char *)&Aj,sizeof(Aj); tfile.close(); void aadbook() /新增图书 int num;char name12;char writer10;int n; a: ofstream fout(allb

13、ook.txt,ios:app); cout 请录入图书信息:endl; cout 书名 t书号 t作者 name;foutnamenum;foutnumwriter;foutwritern; fout.close(); cout 是否继续录入?1. 是 2. 否n; if(n=1) goto a; else void studentland(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 16 页 - - - - - - - - - studentland();

14、void delate() /删除函数 int m; cout 选择操作选项:endl; cout 1.删除全部信息endl; cout 2.单个删除 m; if(m=1) ofstream file(allbook.txt,ios:trunc); cout 全部删除完毕,按任意键返回!endl; file.close(); getch(); system(cls); void studentland(); studentland(); char str1080,buf20; a: int i=0,flag=100,c=0; ifstream fin(allbook.txt); if(!fin

15、) cout 文件打开失败!endl; getch(); system(cls); void studentland(); studentland(); cout 请输入你要删除的书名:buf; strcat(buf,t); while(fin.getline(stri,80) if(strncmp(stri,buf,strlen(buf)=0) flag=i; i+; fin.close(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 16 页 - - - - -

16、 - - - - if(flag=100) cout 没有你所要删除的书籍!重新按1,否则 0.b; if(b=1)goto a; else c=1; if(c=0) ofstream fout(allbook.txt); for(int j=0;ji;j+) if(j=flag)continue; foutstrjendl; fout.close(); cout 你要删除的书籍的信息已删除, 继续按 1,否则按0.b; if(b=1)goto a; cout 操作已经结束,按任意键返回.endl; getch(); system(cls); void studentland(); stude

17、ntland(); void searchbook() / 查找书籍 a: ifstream fin; int flag=0,b,length; char str20; char f200;char g200; fin.open(allbook.txt); if(!fin) coutOpen f1.dat error.endl; exit(1); while(1) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 16 页 - - - - - - - - - coutstr

18、; strcat(str,t); length=strlen(str); cout-endl; while(fin.getline(f,199) strcpy(g,f); if(strncmp(str,f,length)=0) flag=1; break; if(flag=1) cout 所查询的书已经找到:n; cout-endl; cout 书名 t书号 t作者 tendl; coutgendl; cout-endl; flag=0; cout 要继续查询按1,否则按0: b; if(b=0)break; else fin.close(); cout 没有此书 ,继续按 1,否则按0.b;

19、 if(b=0)break; goto a; fin.close(); cout 查询完毕,按任意键返回.endl; getch(); system(cls); void studentland(); studentland(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 16 页 - - - - - - - - - void seachreader() / 查询读者信息 a: ifstream fin; int flag=0,b,length; char str2

20、0; char f200;char g200; fin.open(readernum.txt); if(!fin) cout 没有此信息文件!endl; exit(1); while(1) coutstr; strcat(str,t); length=strlen(str); cout-endl; while(fin.getline(f,199) strcpy(g,f); if(strncmp(str,f,length)=0) flag=1; break; if(flag=1) cout 所查询的读者已经找到:n; cout-endl; cout 名字 t编号 t年龄 t借书次数 endl;

21、coutgendl; cout-endl; flag=0; cout 要继续查询按1,否则按0: b; if(b=0)break; goto a; else 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 16 页 - - - - - - - - - fin.close(); cout 没有此人 ,继续按 1,否则按0.b; if(b=0)break; goto a; fin.close(); cout 查询完毕,按任意键返回.b; file.close(); else

22、 cout没有文件 ; cout 已有的读者个数:; coutbendl; reader *A=new readerb; ifstream is(reader.txt,ios_base:binary); if(is) for(i=0;ib;i+) is.read(char *)&Ai,sizeof(Ai); else couttxt文件打开出错 endl; is.close(); couta; for(i=0;ib;i+) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共

23、 16 页 - - - - - - - - - if(strcmp(Ai.getname(),a)=0) cout 编号年龄名字借书情况 endl; coutAi.getnumber() Ai.getage() Ai.getname() Ai.getborrowbook()endl; h+; if(h=0)cout没有这个读者!; */ void Librarianland() /管理员登陆函数 int q,l=1,i,h; system(cls); system(color 2e); cout endl; cout endl; cout endl; cout i; while(l) if(i

24、=00000) system(cls); system(color 3e); cout endl; cout endl; cout endl; cout |* 0,返回上一级菜单. *|endl; cout |* 1,查询图书馆管理员的信息 *|endl; cout |* 2,存入新的管理员信息. *|endl; cout |* 3,修改图书管理员的信息 *|endl; cout |* 4,新增图书 *|endl; cout |* 5,删除图书 *|endl; coutq; if(q=0&q6) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - -

25、- - - - 名师精心整理 - - - - - - - 第 12 页,共 16 页 - - - - - - - - - switch(q) case 0: l=0; break; case 1:serchLaninf(); system(pause); break; case 2:storelibrarian(); system(pause); case 3:reLaninf(); system(pause); break; case 4: void aadbook(); aadbook(); break; case 5: void delate(); delate(); break; de

26、fault: break; else system(cls); system(color 4e); cout endl; cout endl; cout endl; cout 操作无效! endl; cout endl; cout endl; cout endl; system(pause); else system(cls); system(color 2e); cout endl; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 16 页 - - - - - - -

27、 - - cout endl; cout endl; cout 身份确认失败 endl; cout 是否重新确认!endl; cout 重新确认请按请按1, 放弃请按0endl; couth; if(h=0) l=0; if(h=1) system(cls); system(color 2e); cout endl; cout endl; cout endl; cout i; void studentland() /学生登陆函数 int h; char l=y; while(l=y) system(cls); system(color 3e); cout endl; cout endl; co

28、ut endl; cout endl; cout endl; cout endl; cout * |输出藏书信息 , 请按 1 | *endl; cout * |查询图书馆的总信息,请按2| *endl; cout * |按书名查找图书, 请按 3 | *endl; cout * |查询读者的信息, 请按 4 | *endl; cout * |返回上一级菜单, 请按 0 | *endl; couth; if(h=0&h5) switch(h) case 0: l=n; break; case 1:outbookinf(); system(pause); break; case 2:libary

29、(); system(pause); break; case 3:searchbook(); system(pause); break; case 4:seachreader(); system(pause); break; else system(cls); system(color 4e); cout endl; cout endl; cout endl; cout 您的操作是无效的! ! ! !endl; system(pause); void main() / 主函数 int h,l=1; while(l) system(cls); system(color 7c); cout end

30、l; cout endl; cout endl; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 15 页,共 16 页 - - - - - - - - - cout 图书管理系统endl; cout endl; cout endl; cout -endl; cout |管理员登陆请按 1|endl; cout |学生登陆请按 2 |endl; cout |退出系统请按 0 |endl; cout -endl; coutendl; couth; if(h=0&h3) switch(h

31、) case 0: cout 谢谢光临本图书馆!endl; exit(0); case 1: Librarianland(); system(pause); break; case 2: studentland(); system(pause); break; else system(cls); system(color 4e); cout endl; cout endl; cout endl; cout 您的操作是无效的! ! ! !endl; system(pause); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 16 页,共 16 页 - - - - - - - - -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com