




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
图书管理系统设计图书管理系统设计 C C 实习报告实习报告 学号 学号 班级 班级 姓名 姓名 用 C 设计一个小型的图书管理系统 一 目的 1 学会在自己的软件工程中利用 STL 提供的成熟数据类型 class 这里主要要用的类有 ostream 包括 两个对象 cin 与 cout 以及读文件类 ifstream 与写文件类 ofstream 等 string istringstream 等 2 掌握冒泡法 掌握数据类型大小 operator 的重载 进而利用冒泡法对数据进行排序 3 重点学习文件读写方式 4 了解开发简单应用程序的全过程 包括 分析 设计 编程 调试和编写报告 二 摘要 1 可以预览所有图书的所有内容 2 可以向系统的任意地方插入图书 3 可以删除任意一本图书 4 可以用多种方试查找所耐须要的图书 5 将图书信息保存到到文本文件中 三 系统设计 用记事本新建一文本文件文本文件 文件名为 book txt 将某图书信息输入到这个文件中 菜单系统 系统实现 启动系统之后 出现如下界面 1 预览文本文件文本文件 book txt 中的内容 运行程序后 选择 1 显示文本文件文本文件 book txt 中的内容 2 查找 运行程序后 选择 2 进行查找 图书管理系统 预览查找保存添加退出 编号作者书名退出 删除 3 添加 保存 运行程序后 选择 3 进行添加并保存到 book txt 中保存 此时 book txt 中的内容为 5 删除 保存 程序如下 1 图书类 1 书籍书籍类头文件内容 pragma once include include include using namespace std class CBook public string ID string name string author string press string public time float price CBook next friend ostream 2 书籍书籍类实现文件内容 include stdafx h include CBook h ostream return input 2 链表链表 1 链表类的头文件 include CBook h class Link CBook head CBook p public int creat 创建一个链表 int insert 插入一本书 int del 删除一本书 void find 查找一本书 void show 显示所有图书 void menu 总菜单 void del menu 删除菜单 void insert menu 插入菜单 void find menu 查找菜单 void put into file 写入文本文件中 2 链表的实现链表的实现 include stdafx h include Link h include CBook h include include include include using namespace std int Link creat 创建一个链表 head new CBook p head char str 255 ifstream infile book txt if infile cerr open error p p next new CBook p p next p next 0 p head infile close return 0 int Link insert 插入一本书 int num while 1 insert menu CBook q new CBook cin num if num 1 cout q q next head p q else if num 2 cout q cout str while p name str p p next q next p next p next q p head else break p head return 0 int Link del 删除一本书 int num while 1 del menu cin num if num 1 p p next else if num 2 cout str p head while p next ID str p p next CBook q q p next p next q next p head else break p head return 0 void Link find 查找一本书 int num while 1 find menu cin num if num 1 cout str bool prime false while p next 0 if p ID str prime true cout p next if prime false cout error this book is not exit n else if num 2 cout str bool prime false while p next 0 if p name str prime true cout p next if prime false cout error this book is not exit n else if num 3 cout str bool prime false while p next 0 if p author str prime true cout next if prime false cout error this book is not exit n else if num 4 cout str bool prime false while p next 0 if p press str prime true cout p next if prime false cout error this book is not exit n else if num 5 cout str bool prime false while p next 0 if p public time str prime true cout p endl p head if prime false cout error this book is not exit n else if num 0 break else cout operate error next 0 cout p next p head void Link menu cout 图书管理系统 n cout 1 预览2 查找3 添加 4 保存 5 删除 0 退出 endl cout n cout endl void Link insert menu cout 按什么方式添加 n cout 1 从头添加 2 从中间或末尾添加 0 退出添加 n cout n void Link del menu cout 按什么方式删除 n cout 1 从头删除 2 从中间或末尾删除 0 退出删除 n cout n void Link find menu cout 按什么方式查找 n cout 1 编号 书名 作者 出版社 出版时间 0 退出查找 endl cout n void Link put into file ofstream outfile book txt outfile seekp 0 ios beg outfile 编号 书名 作者 出版社 出版时间 next next 0 outfile p next outfile p p head outfile close 3 主函数 2008程序设计 cpp 定义控制台应用程序的入口点 include stdafx h include CBook h include Link h include using namespace std Link CB int tmain int argc TCHAR argv CB creat while 1 CB menu cout num if num 1 CB show else if num 2 CB find else if num 3 C
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电路基础试题及答案专题
- 2025版权许可合同简易版
- 2025签订租赁合同时的关键要点
- 2025年艺术表演场馆服务项目合作计划书
- 《轴和轴毂联接》课件
- 《优化管理智慧课件:精通人心的领导策略》
- 面对挑战的商务英语备考试题答案
- 《绩效管理策略与应用》课件
- 《骨关节炎护理概要》课件
- 2025-2030年高压金属膜电阻器项目投资价值分析报告
- 2025年区块链工程师技能测评试卷:区块链分布式账本技术实操考核
- 2025商业店铺买卖合同范本下载
- (二模)2025年汕头市高三普通高考第二次模拟考试语文试卷(含答案)
- 河北开放大学2025年《医药企业管理》形成性考核1-4答案
- 2025届宁夏回族自治区银川市第一中学高考全国统考预测密卷语文试卷含解析
- 101二元一次方程组的概念【9个必考点】(必考点分类集训)(人教版2024)(原卷版)
- 2024年建投国电准格尔旗能源有限公司招聘笔试真题
- 【9化一模】2025年安徽合肥市第四十五中学九年级中考一模化学试卷(含答案)
- 全国医师定期考核公共卫生考核试题500+题
- (高清版)DB33∕T 386-2013 内河航道工程质量检验规范
- 铝加工深井铸造培训
评论
0/150
提交评论