欢迎来到天天文库
浏览记录
ID:44604062
大小:405.68 KB
页数:25页
时间:2019-10-24
《媒体库管理系统《图书馆管理》》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#include//清屏头文件usingnamespacestd;#definemax1000〃最大容量intnuml=0,num2=0,num3=0;〃物品数量structBook{charid[20],title[20],author[20],grade[20],press[20],ISBN[20],page[10];1;Bookbook[max];voida
2、dd1()〃添加{ofstreamoutfile("book.txt",ios::binary);if(!outfile){cerr«M打开错误!u«endl;abort();}chara;if(numl>max)〃如果当前数组的空间己满,提示用户不能再添加;{cout«H空间已满,不能再添加了。”vvendl;return;}else{for(inti=numl;i<=max;i++){cout«n请输入你要添加图书的编号:H«endl;cin»book[i].id;cout«H请输入你要添加图书的标题:H«en
3、dl;cin»book[i].titie;cout«H请输入你要添加图书的作者:”vvendl;cin»book[i].author;cout«H请输入你要添加图书的评级(未评级、一般、成人、儿童):,r«endl;cin»book[i].grade;cout«n请输入你要添加图书的出版社:M«endl;cin»book[i].press;cout«H请输入你要添加图书的ISBN;M«endl;cin»book[i].ISBN;cout«n请输入你要添加图书的页数:”vvendl;cin»book[i].page;
4、numl++;cout«H你是否继续添加图书信息?是(y):否(n):H«endl;cin»a;if(a==*n,
5、
6、a==,N,)break;}for(inti=O;i<=numl;i++){outfile.write((char*)&book[i],sizeof(bookfil));outfile.write((char*)&num1,sizeof(num1));}outfile.closeO;voidoutput1()〃图书显示{ifstreaminfilel(nbook.txt,ios::binary);
7、if(!infile1){cerrvv”打开错误!H«endl;abort();}for(inti=0;i<=numl;i++){infilel.read((char*)&book[i],sizeof(book[i]));infileLread((char*)&numl,sizeof(numl));}cout«"所有图书物品的信息如下:"VVendl;for(i=0;i8、豎cout«book[i].id«endl;cout«n图书标题:”;cout«book[i].title«endl;cout«n图书作者:”;cout«book[i].author«endl;cout«H图书评级(未评级、i般、成人、儿童):”;cout«book[i].grade«endl;cout«H图书出版社:“;cout«book[i].press«endl;cout«H图书ISBN:“;cout«book[i].ISBN«endl;cout«n图书页数:”;infilel.close();voidsea9、rch1()//查找图书{ifstreaminfile1(^book.txt^Josirbinary);if(!infilel){cerr«n打开错误!n«endl;abort();}for(inti=0;i<=numl;i++){infile1.read((char*)&book[i],sizeof(book[i]));infile1.read((char*)&num1,sizeof(num1));}charb;stringc;cout«H请输入你要查询的图书的查询方式:(1或2)n«endl;cout«H1.按10、照标题查询2.按照编号查询H«endl;cin»b;if(b==T){cout«n请输入你要查询图书的标题:”vvendl;cin»c;for(i=0;i
8、豎cout«book[i].id«endl;cout«n图书标题:”;cout«book[i].title«endl;cout«n图书作者:”;cout«book[i].author«endl;cout«H图书评级(未评级、i般、成人、儿童):”;cout«book[i].grade«endl;cout«H图书出版社:“;cout«book[i].press«endl;cout«H图书ISBN:“;cout«book[i].ISBN«endl;cout«n图书页数:”;infilel.close();voidsea
9、rch1()//查找图书{ifstreaminfile1(^book.txt^Josirbinary);if(!infilel){cerr«n打开错误!n«endl;abort();}for(inti=0;i<=numl;i++){infile1.read((char*)&book[i],sizeof(book[i]));infile1.read((char*)&num1,sizeof(num1));}charb;stringc;cout«H请输入你要查询的图书的查询方式:(1或2)n«endl;cout«H1.按
10、照标题查询2.按照编号查询H«endl;cin»b;if(b==T){cout«n请输入你要查询图书的标题:”vvendl;cin»c;for(i=0;i
此文档下载收益归作者所有