图书馆管理系统代码_第1页
图书馆管理系统代码_第2页
图书馆管理系统代码_第3页
图书馆管理系统代码_第4页
图书馆管理系统代码_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

include define DEBUG 0 宏定义 决定测试代码是否编译 0 为不编译 非 0 则编译 const char book path 20 books txt const char reader path 20 readers txt 文件读写声明 void read from files to vector void write all to files if DEBUG void scan readers for reader endif int main 完成操作后需要在控制台按 5 中退出才会保存到文件 wcin imbue china wcout imbue china read from files to vector if DEBUG cout size of readers readers size endl cout size of books books size endl scan book scan readers endif string password 密码已改 cout 欢迎使用中南大学网络在线图书系统 endl 这里可以添加你们小组的名单或一些装饰的字符 cout 请选择登录方式 endl cout 1 管理员登陆 2 读者登陆 a cleanScreen if a 1 string str for int j 0 j 4 j cout 请输入管理密码 你有 4 j 次机会 str if password str break else cout 密码错误 请重新输入 endl if j 4 return 0 cleanScreen cout 欢迎来到图书管理系统 endl cout 成功登陆 你有以下操作可供选择 endl cout endl 操作循环 cout 1 浏览图书信息 endl cout 2 图书信息修改 endl cout 3 图书信息添加 endl cout 4 图书信息删除 endl cout 5 保存信息并退出系统 endl cout 请选择操作选项编号 b cleanScreen while b 5 switch b case 1 scan book break case 2 modify book break case 3 add book break case 4 delete book break default cout 输入错误 请重新输入 break cout endl cout 请进行下一次操作 endl cout 1 浏览图书信息 endl cout 2 图书信息修改 endl cout 3 图书信息添加 endl cout 4 图书信息删除 endl cout 5 退出系统 endl cout 请选择操作选项编号 b cleanScreen write all to files return 0 else if a 2 int readerIndex 0 记录读者下标 输入学号登陆 cout 请输入学号 endl wchar t studentnumber 20 for int m 0 m 9 m cout 请输入学号 你有 9 m 次机会 studentnumber int t for t 0 t readers size t if wcscmp studentnumber readers t cardnum 0 readerIndex t break 判断跳出循环原因 if t readers size break else cout 登录账号不存在 请重新输入学号 endl continue if m 9 return 0 cleanScreen cout 欢迎来到读者自助系统 endl wcout L 欢迎你 readers readerIndex name L 你有以下操作可供选择 endl cout endl 操作循环 cout 1 图书浏览 endl cout 2 图书查询 endl cout 3 图书借阅 endl cout 4 图书返还 endl cout 5 退出系统 endl cout 请选择操作选项 c cleanScreen while c 5 switch c case 1 scan book break case 2 search book break case 3 borrow book readerIndex break case 4 return book readerIndex break default cout 输入错误 请重新输入 endl break cout endl cout 请进行下一次操作 endl cout 1 图书浏览 endl cout 2 图书查询 endl cout 3 图书借阅 endl cout 4 图书返还 endl cout 5 退出系统 endl cout 请选择操作选项 c cleanScreen write all to files return 0 return 0 main 函数结束 写入 读取文件 void write all to files wofstream outfile outfile imbue locale chs 写入书本文件 outfile open book path outfile books size n for int i 0 i books size i outfile books i outfile close outfile clear 写入读者文件 由于程序中没有针对读者的删改 备用 将 0 改为 1 后即可编译这段代 码 if 0 outfile open path reader path outfile readers size n for int i 0 i readers size i outfile size while infile eof books push back bb size infile close infile clear 读取读者数据 infile open reader path infile size while infile eof readers push back rr size infile close return include classes h locale china chs use china character void printout book book 这个函数我用重载运算符 的函数代替了 对应全局变量的定义 vector books vector readers book 重载操作符函数定义 wistream cout 请输入书名 b title cout 请输入作者名 b firstauthor cout 请输入出版社 b publisher cout 请输入印刷日期 年 月 b birthday cout 请输入所属类别 b location cout 请输入价格 b price cout 请输入数量 b number return in wostream return in wofstream cout 请输入性别 男为 女为 r s cout 请输入卡号 r cardnum cout 请输入学位 学士为 硕士为 博士为 r e r already 0 已借书本数默认为 0 return in wostream out r name out r s out r e out r already wifstream return in wofstream return out main 函数中调用定义 void scan book 建立浏览函数 for int i 0 i books size i wcout books i void search book 建立搜索函数 int g cout 你有以下查询方式可供选择 endl cout 1 按书名查询 endl cout 2 按编号查询 endl cout 3 按作者查询 endl cout 请选择查询方式 g switch g case 1 wchar t name 20 cout 请输入书名 name for int r 0 r books size r if wcscmp books r title name 0 wcout books r return cout 查无此书 endl return break case 2 int str cout 请输入图书编号 str for int l 0 l books size l if books l id str wcout books l return cout 查无此书 endl return break case 3 wchar t auth 10 cout 请输入图书作者 auth for int p 0 p books size p if wcscmp books p firstauthor auth 0 wcout books p return cout 查无此书 endl return break default cout 查无此书 5 cout 抱歉 你的借书数已满 不可再借 endl return int log cout 请输入要借出图书的登陆号 log for int i 0 i 0 int y cout 确认借出书籍吗 确认请输入 1 取消请输入 0 y if y 1 cout 借阅成功 books i number readers t already return else return else cout 图书已借完 endl return cout 图书不存在 endl return void return book int t 建立还书函数 int log cout 请输入要归还的图书的登陆号 log for int i 0 i books size i if log books i id cout 图书归还成功 endl books i number readers t already return cout 图书不存在于本图书馆 无需归还 endl return void modify book 建立修改函数 int log cout 请输入要修改的图书编号 log for int i 0 i books size i if log books i id cout 需修改图书信息如下 endl wcout books i cout 请输入修改后的信息 books i return cout 图书不存在 无法修改 endl return void delete book int log cout 请输入要删除的图书编号 log 迭代器实现删除指定图书 vector iterator itor2 for vector iterator iter books begin iter books end if log iter id cout 将删除的图书信息如下 endl wcout iter

温馨提示

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

评论

0/150

提交评论