欢迎来到天天文库
浏览记录
ID:33141401
大小:45.00 KB
页数:15页
时间:2019-02-21
《王万青,图书馆管理完整》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、个人收集整理勿做商业用途#include//字符串头文件#include//文件头文件#include//是指标准库中输入输出流地头文件,cout就定义在这个头文件里文档来自于网络搜索usingnamespacestd;//使用名字空间stdconstintBMAX=50;//书最多个数//图书管理模块//图书类classbook{public:intno;//图书编号文档来自于网络搜索charname[20];//图书名称文档来自于网络搜索intb_flag;//1为在架,2为借出文档来自于网络搜索intb_del;//1为存在,2为删
2、除文档来自于网络搜索public:book(){}//构造函数voidsetno(intn){no=n;//图书编号取值}intgetno(){returnno;//返回图书编号值}voidsetname(charna[]){strcpy(name,na);//字符串复制}char*getname(){returnname;//返回图书名称}voidborbook(){b_flag=2;//借书标志}voiddelbook(){b_del=2;//删除标志}voidaddbook(intno,charna[])//增加图书功能{setno(no);个人收集整理勿做商业用途setname(na
3、);b_flag=1;b_del=1;}};//图书数据库类classbdatabase{public:bookbtarray[BMAX];//图书集合文档来自于网络搜索inttop;public:bdatabase(){bookb;top=-1;fstreamfile("book.txt",ios::in);//打开文件while(1){file.read((char*)&b,sizeof(b));if(!file)break;top++;btarray[top]=b;}file.close();//关闭文件}~bdatabase()//析构函数,将btarray[]写到book.txt文
4、件中文档来自于网络搜索{fstreamfile("book.txt",ios::out);for(inti=0;i<=top;i++){if(btarray[i].b_del==1)file.write((char*)&btarray[i],sizeof(btarray[i]));文档来自于网络搜索}file.close();}voidaddbooks()//往图书数据库中加图书文档来自于网络搜索{bookbk;个人收集整理勿做商业用途intno;charbname[20];cout<<"请输入书号:";cin>>no;cout<>bname;cout
5、<>no;for(inti=0;i<=top;i++){if(btarray[i].no==no&&btarray[i].b_del==1){returni;}}return-1;}intfindbooks()//查找图书,这个函数用于图书维护文档来自于网络搜索{intno;cha
6、rvalue[6];cout<<"请输入书号:";cin>>no;for(inti=0;i<=top;i++){if(btarray[i].no==no&&btarray[i].b_del==1){if(btarray[i].b_flag==1)strcpy(value,"在架");if(btarray[i].b_flag==2)strcpy(value,"借出");cout<<"书号:"<7、;}voideditbooks()//编辑图书文档来自于网络搜索{intcur;cur=findbooks();if(cur==-1){cout<<"没有这本书"<
7、;}voideditbooks()//编辑图书文档来自于网络搜索{intcur;cur=findbooks();if(cur==-1){cout<<"没有这本书"<
此文档下载收益归作者所有