ImageVerifierCode 换一换
格式:DOCX , 页数:19 ,大小:272.72KB ,
资源ID:4176754      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4176754.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(图书管理系统.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

图书管理系统.docx

1、图书管理系统图书管理系统设计(C+)实习报告 学号: 班级: 姓名: 用C+设计一个小型的图书管理系统一、目的 1、学会在自己的软件工程中利用STL提供的成熟数据类型(class),这里主要要用的类有:ostream(包括两个对象cin与cout,以及读文件类ifstream与写文件类ofstream等)、string istringstream等;2、掌握冒泡法。掌握数据类型大小(operator )的重载,进而利用冒泡法对数据进行排序。3、重点学习文件读写方式。4、了解开发简单应用程序的全过程,包括:分析、设计、编程、调试和编写报告。二、摘要 1.可以预览所有图书的所有内容. 2.可以向系

2、统的任意地方插入图书. 3.可以删除任意一本图书. 4.可以用多种方试查找所耐须要的图书. 5.将图书信息保存到到文本文件中三、系统设计用记事本新建一文本文件,文件名为:“book.txt”,将某图书信息输入到这个文件中菜单系统图书管理系统保存删除退出添加查找预览 退出书名作者编号系统实现启动系统之后,出现如下界面:1 预览文本文件“book.txt”中的内容运行程序后,选择1(显示文本文件“book.txt”中的内容)2.查找运行程序后, 选择2进行查找.3添加、保存运行程序后,选择3进行添加并保存到”book.txt”中保存此时”book.txt”中的内容为5. 删除、保存程序如下1、图书

3、类: (1) 书籍类头文件内容#pragma once#include #include #include using namespace std;class CBookpublic: string ID; string name; string author; string press; string public_time; float price; CBook *next; friend ostream& operator (istream& input,CBook &book);(2) 书籍类实现文件内容#include stdafx.h#include CBook.hostream&

4、 operator (ostream& output, CBook&book) outputbook.ID setiosflags(ios:left)setw(8)book.name book.author book.presstsetw(12)book.public_time (istream& input,CBook &book) inputbook.ID book.name book.author book.press book.public_time book.price ; return input;2链表1) 链表类的头文件#include CBook.hclass Link CB

5、ook *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#in

6、clude #include #include #include using namespace std;int Link:creat () /创建一个链表 head=new CBook; p=head; char str255; ifstream infile(book.txt); if(!infile) cerropen 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_

7、menu(); CBook *q=new CBook; cinnum; if(num=1) cout*q; q-next =head; p=q; else if(num=2) cout*q; coutstr; 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(); cinnum; if(num=1) p=p-next ; else if(num=2) co

8、utstr; 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(); cinnum; if(num=1) coutstr; bool prime=false; while(p-next !=0) if(p-ID=str) prime=true; cout*pnext ; if(prime=false) cou

9、terror!this book is not exit!n; else if(num=2) coutstr; bool prime=false; while(p-next !=0) if(p-name =str) prime=true; cout*pnext ; if(prime=false) couterror!this book is not exit!n; else if(num=3) coutstr; bool prime=false; while(p-next !=0) if(p-author =str) prime=true; coutnext ; if(prime=false)

10、 couterror!this book is not exit!n; else if(num=4) coutstr; bool prime=false; while(p-next !=0) if(p-press =str) prime=true; cout*pnext ; if(prime=false) couterror!this book is not exit!n; else if(num=5) coutstr; bool prime=false; while(p-next !=0) if(p-public_time=str) prime=true; cout*pendl; p=hea

11、d; if(prime=false) couterror!this book is not exit!n; else if(num=0) break; else coutoperate error!next !=0) cout*pnext ; p=head; void Link:menu () cout*图书管理系统*n; cout*1.预览2.查找3.添加 4.保存 5.删除 0.退出endl; cout*n; coutendl; void Link:insert_menu() cout-按什么方式添加-n; cout*1.从头添加 2.从中间或末尾添加 0.退出添加n ; cout-n;

12、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*pnext

13、; 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 (); coutnum; if(num=1) CB.show (); else if(num=2) CB.find (); else if(num=3) CB.insert (); else if(num=4) CB.put_into_file (); else if (num=5) CB.del (); else if(num=0) break; else couterror!endl; break; return 0;1. 将类的声明和成员函数的定义分离,体现封装性,也便于调试和改正。2. 用动态链表将不同的书连接起来,以便进行插入和删除等操作

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1