数据结构课程设计图书管理系统

上传人:仙*** 文档编号:31859456 上传时间:2021-10-13 格式:DOC 页数:17 大小:57.50KB
收藏 版权申诉 举报 下载
数据结构课程设计图书管理系统_第1页
第1页 / 共17页
数据结构课程设计图书管理系统_第2页
第2页 / 共17页
数据结构课程设计图书管理系统_第3页
第3页 / 共17页
资源描述:

《数据结构课程设计图书管理系统》由会员分享,可在线阅读,更多相关《数据结构课程设计图书管理系统(17页珍藏版)》请在装配图网上搜索。

1、/*这是本人大二做数据结构课程设计的一个题目 已编译通过用户首先以管理员身份登陆 初始密码000000然后再添加图书和其他用户 程序中还有许多问题 ,有好的意见可以提出来 谢了*/#include#include#include#include#include#include #include#includeusing namespace std;/*书类定义*/class Bnodeprivate:string B_name; /书名 string B_author; /作者string B_no; /编号string B_pub; /出版社 int B_sum; /馆藏量 bool tok

2、e; / 是否可借标记 string bow_time; /借书时间 string ret_time; /还书时间Bnode *next;public:Bnode()next=NULL;Bnode()friend class Administrate;friend class Unode;/*用户类定义*/class Unodeprivate:string U_name,U_password;Bnode *borrow,*history,current;Unode *next;public:Unode(string password=000000) borrow=new Bnode; hist

3、ory=new Bnode; next=NULL; U_password=password; Unode()Unode* enter(Unode *h);void search_Book(Bnode *h);void guanli(Bnode *h1,Unode *h2);void bowrrow_Book(Bnode *h1,Unode *h2);void return_Book(Bnode *h1,Unode *h2);void show_current(Unode *h);void show_history(Unode *h);void setcode(Unode *h);friend

4、class Administrate;/*管理员定义*/class Administrateprivate:string A_password;public: Administrate(string password=000000)A_password=password;Administrate()void enter();void add_Unode(Unode *h); void add_Bnode(Bnode *h);void show_Unode(Unode *h);void show_Bnode(Bnode *h);void delete_Unode(Unode *h);void d

5、elete_Bnode(Bnode *h);void setcode();void main()int code,code1,code2;Administrate A;Unode *user,U,*u;Bnode *book,B,*b;user =new Unode;book =new Bnode;cout *endl;cout * 图书管理系统 *endl;cout * *endl; cout * *endl; cout * *endl; cout * *endl; cout * *endl; cout * 版权所有:Jason *endl;cout *endl;loop:coutcode;

6、switch(code)case 1: A.enter(); system(cls); system(date /t); system(time /t); do cout * endl;cout * 1 添加用户 * endl; cout * 2 删除用户 * endl; cout * 3 添加图书 * endl;cout * 4 删除图书 * endl; cout * 5 修改密码 * endl; cout * 6 返回登录界面 * endl; cout * endl;cout code1;switch(code1)case 1:system(cls); A.add_Unode(user);

7、 A.show_Unode(user); coutendl; break;case 2:system(cls); A.delete_Unode(user); A. show_Unode(user); break;case 3:system(cls); A.add_Bnode(book); A.show_Bnode(book); break;case 4:system(cls); A.delete_Bnode(book); A.show_Bnode(book); break;case 5:system(cls); A.setcode(); break;case 6:system(cls);got

8、o loop;break;while(code=6);break;case 2: u=U.enter(user); do system(cls); system(date /t); system(time /t); cout*endl; cout*1 图书查询 * endl; cout*2 借阅管理 * endl; cout*3 修改密码 *endl; cout*4 退出登陆 *endl; cout*endl; cout请选择操作类型 code2; switch(code2) case 1: system(cls); U.search_Book(book);break; case 2: sys

9、tem(cls);U.guanli(book,u);break; case 3: system(cls);U.setcode(u);break; case 4: system(cls); goto loop;break; while(code=4); break; /switch end/main end/*管理员登陆函数定义*/void Administrate:enter() char ss7; cout 请输入密码:;for(int j=0;j3;j+)for (int k=0;k6;k+)ssk=getch();cout*; ; ss6=0;if (ss!=A_password)/*密

10、码匹配*/cout endl; cout 密码错误,请重新输入! endl;cout 请输入密码:;else break;continue;if(j=3) exit(-1);/*登陆三次后还未成功则结束程序*/cout endl 管理员登陆成功!请选择操作类型 : next !=NULL)tail=tail-next;pnew=new Unode;coutm;while(m!=end)pnew=new Unode;pnew-U_name=m;tail-next=pnew;tail=pnew;coutm;/*管理员创建图书链表函数定义*/void Administrate:add_Bnode(B

11、node *h)Bnode *pnew,*tail=h;int i=1,n,m;while(tail-next !=NULL)tail=tail-next ;dopnew=new Bnode;coutendl;cout图书i:endl;coutpnew-B_name;coutpnew-B_author; coutpnew-B_no;coutpnew-B_pub;coutm;if(m=0&mB_sum=m; break;elsecout输入错误,馆藏量应为整数! 请重新输入:;/cerrtoke=true;tail-next=pnew;tail=pnew; coutendl;i+;coutn;

12、if(n=2) break;while(1);/*管理员删除用户函数*/void Administrate:delete_Unode(Unode *h)Unode *p,*q;p=h;q=h-next;string m;coutm;while(q!=NULL&q-U_name!=m) p=q;q=q-next;if(q=NULL)cout所要删除的用户不存在!next=q-next;free(q);/*管理员删除图书函数*/void Administrate:delete_Bnode(Bnode *h)Bnode *p,*q;p=h;q=h-next;string m;coutm;while(

13、q!=NULL&q-B_name!=m) p=q;q=q-next;if(q=NULL)cout所要删除的图书不存在!next=q-next;free(q);/*显示用户函数*/void Administrate:show_Unode(Unode *h)/system(cls);int i=1;Unode *p;p=h-next;while(p!=NULL) cout用户i:U_namenext; i+;/*显示图书函数*/void Administrate:show_Bnode(Bnode *h)/system(cls);Bnode *p;int i=1;p=h-next;while(p!=

14、NULL) cout图书iendl; coutB_nameendl; coutnext; /*管理员设置密码函数*/void Administrate:setcode()coutA_password;/*用户登陆函数*/Unode* Unode:enter(Unode *h)Unode *p;string m;char ss7;p=h-next;lp1:coutm;while(p-U_name !=m&p!=NULL)p=p-next;if(p=NULL) cout该用户不存在!;goto lp1;elsecout请输入用户密码:; for(int j=0;j3;j+)for (int k=0

15、;k6;k+)ssk=getch();coutU_password)cout endl; cout 密码错误,请重新输入! endl;coutnext;coutendl;coutm;while(p!=NULL&m!=p-B_name)p=p-next; if(p=NULL) cout所要查询的书籍不存在!;else cout书名;coutB_name endl;cout作者;coutB_authorendl;cout编号;coutB_noendl;cout出版社;coutB_pub endl;cout馆藏量;coutB_sumendl; coutcode;while(code=1);/*用户管

16、理图书函数*/void Unode:guanli(Bnode *h1,Unode *h2) int code ;system(cls);docout1.借阅图书 endl; cout2.归还图书 endl; cout3.当前借阅 endl; cout4 借阅历史 endl;cout5.退出 endl;coutcode;switch(code)case 1:system(cls); bowrrow_Book(h1,h2); break;case 2: system(cls);return_Book(h1,h2);break;case 3: system(cls);show_current(h2)

17、;break;case 4:system(cls);show_history(h2);break;case 5:break; coutendl;coutendl;while(codeborrow;t=h2-history; while(tail-next!=NULL)tail=tail-next; while(t-next!=NULL )t=t-next; while(code=1)p=h1-next;q=new Bnode;n=new Bnode;coutm;while(p!=NULL&p-B_name !=m)p=p-next; if(p=NULL) cout你所要借阅的图书不存在!tok

18、e=true) (p-B_sum)-; q-B_author=p-B_author; q-B_name =p-B_name; q-B_no =p-B_no; q-B_pub =p-B_pub; n-B_author=p-B_author; n-B_name =p-B_name; n-B_no =p-B_no; n-B_pub =p-B_pub; coutq-bow_time;n-bow_time=q-bow_time ; if(p-B_sum=0) p-toke=false; tail-next=q;tail=q;t-next=n;t=n; else coutendl 该书馆藏量已为0,不可借

19、阅!endl;coutcode;/*用户归还图书函数*/void Unode:return_Book(Bnode *h1,Unode *h2)Bnode *p,*q,*t,*n;string m;int code;do q=h2-borrow; p=h1-next; n=h2-history; coutm;while(q!=NULL&q-B_name!=m)t=q;q=q-next; if(q =NULL) cout你并未借阅该书!B_name!=m)n=n-next; coutn-ret_time; t-next=q-next; while(p!=NULL&p-B_name!=m)p=p-n

20、ext;(p-B_sum)+; if(p-B_sum 0) p-toke=true; coutcode;while(code=1);/*用户当前借阅查询*/void Unode:show_current(Unode *h)int i=1;Bnode *p;p=h-borrow-next;cout当前借阅如下endl;while(p!=NULL) cout图书iendl; coutB_nameendl; coutnext; /*用户借阅历史查询*/void Unode:show_history(Unode *h) int i=1;Bnode *p;p=h-history-next;cout借阅历史如下endl;cout*endl;while(p!=NULL)cout图书iendl; cout书名:;coutB_nameendl; cout作者:;coutB_authorendl;cout出版社:;coutB_pubendl;cout编号:; coutB_noendl;cout借书时间:; coutbow_timeendl; cout还书时间:; coutret_timeendl ; cout*next; /*用户设置密码函数*/void Unode:setcode(Unode *h) string m;coutm;h-U_password=m;

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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