图书管理实验报告_第1页
图书管理实验报告_第2页
图书管理实验报告_第3页
图书管理实验报告_第4页
图书管理实验报告_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

实习报告 (2013年) 实习题目:设一本书的基本资料由以下数据项来描述:1. 书号(设为一个无符号长整型);2. 书名(设为不超过30个字符的字符串);3. 作者名(设为不超过20个字符的字符串);4. 出版社(设为不超过30个字符串的字符串);5. 关键词(最多5个,每个关键词为不超过10个字符的英文单词);其中,设每本书的书号,书名,作者名和出版社均是唯一的.请用类形式来构造一个小型图书资料整理系统(模拟).该系统应能提供以下功能:1. 图书资料库:从键盘输入各图书资料,建立图书资料库;设图书依书号从小到大次序组织存放;2. 查询图书功能:1) 读书可通过提供书名查询,若该书仍在库中,则列出该书资料;2) 读者可通过提供书号查询,若该书仍在库中,则列出该书资料;3) 读者也可以通过提供关键词查询(最多5个:一般情况下,读者提供用于查询的关键词个数都不会超过在书库中登记的图书原有的关键词个数),若提供的关键词和原书中关键词相匹配,则列出所有符合要求的所有图书资料个读者选择;读者可从系统所列出可供选择的图书资料信息中,通过书号来办理借阅的手续;3.借书功能:当锁查询的图书的确在库内时,读者可采用提供书号形式来办理借阅手续(每次操作只能借一本书);1)登记借阅人的姓名(不超过20个字符的字符串),电话(无符号长整型整数),借阅日期(年,月.日,均是整形量);4.还书功能:1)删去图书中该书借阅人的资料;2).将该书资料归入”该图书仍在库内”状态;5.催还功能:管理人员定期列出借书人借阅图书资料,以便检查是否有超期借阅者,若有则发通知催还.说明:1. 理论上,图书资料库书量应没有限制(实际上是受硬件资料所限)2. 图书资料库可以采用以下组织形式:) 1)每本图书的资料有基本资料和借阅人资料组成,所有图书资料由一个链表链接在一起; 2)每本图书的资料也由基本资料和借阅人资料组成,但所有图书资料分别由未借出链表和 已借出链表在一起;3.请先确定好图书资料组织形式,然后再考虑设计功能的实现.4.模拟图书资料系统工作的主函数基本要求如下:1)在键盘上输入每本图书资料,在储存区建立图书资料库.因无法预知图书册数,考研题设当输入书号为0时表示输入结束.图书资料库正常工作期间追加新入库图书时也如此办理;2)输出图书库中所有在库图书资料清单,此操作只由管理人员使用;3)输出图书库中已被借出的天数资料清单,此操作只由管理人员使用;4).查询图书.借阅图书.归还图书.追加图书;5)每借出一本图书或归还一本图书之后,输出书库内图书情况或借书人登记资料,以便可对操作是否完成;6)书库内没有登记的图书,不能办理借阅手续.当然,不是在改图书库借出的图书业不能在此处办理还书手续.源程序代码:#include#include#include#include#includestruct Date / 日期数据结构int year; int month; int day;struct Person / 个人信息数据结构char name20; long tele; / the telephone number Date dateb; / 声明dateb是struct Data成员;struct Book / 图书资料信息数据结构long ISBN; / 书号 char Bname31; / 书名 char Bwrite20; / 作者名 char Bprint31; / 出版社名 char *Bkeyword5; / 关键词 Book *link; / 指向下一连节点 Person message; /声明 message是 struct Person 类型);class Library / 图书馆类 protected: Book* librin; / 在书库链 Book* libout; / 借书链 public: Library(); / 构造函数 Library(); / 析构函数 void creat(); / 创建图书馆 void print1(); / 输出在书库图书 void inquire1(); / 书号查询 void inquire2(); / 书名查询 void inquire3(); / 关键词查询 void borrow(); / 借书 void print2(); / 输出借出图书 void invert(); / 还书 void urge(); / 催还图书 void deleter(); / 删除图书 void insert(); / 增加新书;Library:Library() / 构造函数 libout=NULL;Library:Library() / 析构函数 ; int dayth(int Y,int M,int D) / 计算某年某月某日是当年第几天int dy=0; M=M-1; while(M0) do if(M=2) if(Y%4=0)&(Y%100!=0)|(Y%400=0)dy=dy+29;else dy=dy+28; else if(M=8)&(M%2=0) dy=dy+31; else dy=dy+30; M=M-1; while(M0); dy=dy+D; return dy;int Ymday(int Y,int M) / 判断某年某月有几天if(M=2) if(Y%4=0)&(Y%100!=0)|(Y%400=0) return 29; else return 28; else if(M=8)&(M%2=0) return 31; else return 30; int Yeardays(int y) / 判断某年有几天if(y%4=0&y%100!=0)|(y%400=0) return 366; else return 365;long Leapdays(int yy1,int yy2) / 计算某年两年之间相距多少天long y,m,d=0; while(yy1yy2) m=Yeardays(yy1); d=d+m; yy1+; return d;void Library:creat() / 创建图书资料函数 Book *h,*q,*p,*temp,*k;int i=1,j; h=NULL; p=new Book; if( p=NULL ) coutnt Eorror ! ; exit(1); q=p; coutnt -The Book Infornation-n; coutnnNO.i; do coutp-ISBN; if(p-ISBN 0) coutISBN=0) break; while(p-ISBN ISBN 0) coutBname); coutBwrite); coutBprint); coutntInput the Bkeyword:( Input the NULL to end ); for(j=0;j5;j+) coutntNO.j+1Bkeywordj=new char20+1; gets(p-Bkeywordj); if(strcmp(p-Bkeywordj,)=0) break; q-link=NULL; while( p-ISBN!=0 ) i+;if(h=NULL) h=p;if(i2) temp=h; while( p-ISBN temp-ISBN & temp-link!=NULL ) k=temp;temp=temp-link; if ( p-ISBN ISBN ) if(temp=h) p-link=temp;h=p; else k-link=p;p-link=temp; else temp-link=p;p-link=NULL; p=new Book; coutnnNO.i; do coutp-ISBN; if(p-ISBN 0) coutISBN ISBN 0 ) coutBname); coutBwrite); coutBprint); coutntInput the Bkeyword:( Input the NULL to end ); for(j=0;j5;j+) coutntNO.j+1Bkeywordj=new char20+1; gets(p-Bkeywordj); if(strcmp(p-Bkeywordj,)=0) break; q=p; librin=h; / creat endvoid Library:print1() / 输出在书库图书资料函数 int j; Book *p; p=librin; if( librin=NULL ) coutISBN = 0 ) continue; coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; /getch(); for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; / getch(); p=p-link; getch(); while( p!=NULL ); coutn_n; / print1 endvoid Library:inquire1() / 书号查询函数 long num; int j; Book *temp; temp=librin; if(librin=NULL) coutnt This list is NULL!; getch(); exit(1); else coutnum; while(num!=temp-ISBN&temp-link!=NULL)temp=temp-link;if( num=temp-ISBN ) coutnt Your need result is:; coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; coutn_n;else coutnt Sorry,Seek Failure!; getch(); / inquire1 endvoid Library:inquire2() / 书名查询函数 char name30+1; int j; Book *temp; temp=librin; if(librin=NULL) coutnt This list is NULL!; getch(); exit(1); else coutBname,name)!=0)&temp-link!=NULL)temp=temp-link; if( strcmp(name,temp-Bname)=0 ) coutnt Your need result is:; coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; coutn_n; elsecoutnt Soory,Seek Failure!;getch(); / inquire2 endvoid Library:inquire3() / 关键词查询函数 char *keyword5; int i=0,j,d,ct=0,k=0; Book *temp; temp=librin; if(librin=NULL) coutnt This list is NULL!; getch(); exit(1); else coutntInput you need Seek Bkeyword:( Input the NULL to end ); for(j=0;j5;j+) coutntNO.j+1( Input the NULL to end ):; keywordj=new char20+1; i+; gets( keywordj ); if(strcmp( keywordj,)=0 ) break; d=i; while(temp!=NULL) ct=0; for(j=0;jBkeywordi,)!=0&iBkeywordi )=0 ) ct+;break; if(strcmp(temp-Bkeywordi,)=0|i=5) break; if(ct=(d-1) k+; coutnt Your need result is:; coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0)couttBkeywordj; else break; coutlink; if(k=0) coutnt Soory,Seek Failure!; getch(); / inquire3 endvoid Library:borrow() / / 借书函数 Book *p,*temp,*h,*st; long num; if(librin=NULL) coutnt The library is NULL!; return ; temp=librin; p=libout; coutnum; while(temp-ISBN!=num&temp-link!=NULL) st=temp; temp=temp-link; / Scanning if( temp-ISBN=num ) if( temp=librin ) librin=librin-link; else st-link=temp-link; ); couttemp-message.tele; do coutntInput the year(1900=ytemp-message.dateb.year; while(temp-message.dateb.yearmessage.dateb.year2100); do coutntInput the month(1=mtemp-message.dateb.month; while(temp-message.dateb.monthmessage.dateb.month12); couttemp-message.dateb.day; if( libout=NULL ) libout=temp; temp-link=NULL; else while( temp-ISBNp-ISBN&p-link!=NULL ) h=p; p=p-link; if( temp-ISBNISBN ) if( p=libout ) temp-link=p; libout=temp; else h-link=temp; temp-link=p; else if( p-link=NULL ) p-link=temp; temp-link=NULL; coutnt Borrow Success!; else coutnt Soory,Borrow Failure!; / borrow endvoid Library:print2() / 输出借出图书资料 Book *p;int j=0; p=libout; if( libout=NULL ) coutnt Hasnt person borrow!n; else coutnt -The borrow book infornation-; do coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; coutnt - ; coutn Person name:n Tele:message.tele; coutnDate:message.dateb.year/message.dateb.month/message.dateb.day; p=p-link; getch(); while( p!=NULL ); coutn_n; / print2 endvoid Library:invert() / 还书函数Book *temp,*p,*h,*st; int j; long num; temp=librin; p=libout; if( libout=NULL ) coutnt Hasnt person borrow the book!; getch(); return; coutnum; while( p-ISBN!=num&p-link!=NULL ) st=p; p=p-link; if( p-ISBN=num ) coutnt -The invert book infornation-; coutn_n; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; coutn Person name:n Tele:message.tele; coutnDate:message.dateb.year/message.dateb.month/message.dateb.day; coutlink; else st-link=p-link; 0=0; p-message.tele=0; p-message.dateb.year=0; p-message.dateb.month=0; p-message.dateb.day=0; if( librin=NULL ) librin=p;p-link=NULL; else while( p-ISBNtemp-ISBN&temp-link!=NULL ) h=temp; temp=temp-link; if( p-ISBNISBN ) if( temp=librin ) p-link=temp; librin=p; else h-link=p; p-link=NULL; coutnt Invert Success!; else coutnt Soory,The book isnt this library!; getch(); / invert endvoid Library:urge() / 催还图书函数 Book *temp; int j,ct=0,y1,m1,d1,y2,m2,d2,y3,m3,d3; long Dt,D1,D2,D3; temp=libout; coutnt Plase input the date of today:n; do coutntInput the year(1900=yy2; while(y22100); do coutntInput the month(1=mm2; while(m212); coutd2; coutmessage.dateb.year;m1=temp-message.dateb.month;d1=temp-message.dateb.day;d3=d1+20;if( d3Ymday(y1,m1) ) d3=d3-Ymday(y1,m1); m3=m1+1; if( m312 ) m3=1; y3=y1+1; else y3=y1; else m3=m1; y3=y1; D1=Leapdays( y1,y2 );D2=dayth( y1,m1,d1 );D3=dayth( y2,m2,d2 );Dt=D1+D3-D2;if( Dt20 ) coutn _; coutn NO.ISBNn Bname:Bname; coutn Bwrite:Bwriten Bprint:Bprint; coutn Bkeyword:n; for(j=0;jBkeywordj,)!=0) couttBkeywordj; else break; coutn -; coutn Person name:n Tele:message.tele; cout message.dateb.year/message.dateb.month/message.dateb.day; couty3/m3/d3; coutn _; coutnt The person Over time :Dt-20link; if(ct=0) coutnt Hasnt person over time borrow the book!n; getch(); / urge endvoid Library:deleter() / 删除图书函数 Book *st,*temp; long num; temp=librin; coutnum; while( num!=temp-ISBN&temp-link!=NULL ) st=temp; temp=temp-link; if( num=temp-ISBN ) if( temp=librin ) librin=librin-link; else st-link=temp-link; delete temp; coutnt The Node had deleted!n; else coutnt The Node isnt Exist!n; getch(); / delete endvoid Library:insert() / 新增图书函数 Book *temp,*st,*p; int j; p=librin; coutnt -The new book infornation-; temp=new Book; if( temp=NULL ) coutnt Soory,Applicanta Failure!; exit(1); couttemp-ISBN; coutBname); coutBwrite); coutBprint); coutntInput the Bkeyword:( Input the NULL to end ); for(j=0;j5;j+) coutntNO.j+1Bkeywordj=new char20+1; gets(temp-Bkeywordj); if(strcmp(temp-Bkeywordj,)=0) break; if( librin=NULL) librin=temp; temp-link=NULL; else while( temp-ISBNp-ISBN&p-link!=NULL ) st=p; p=p-link; if( temp-ISBNISBN ) if( p=librin ) temp-link=p; librin=temp; else st-link=temp; temp-link=p; else p-link=temp; temp-link=NULL; coutnt Insert success!n; getch(); / insert endvoid main() / 主函数 Book *librin; int NO,NO2,ct=1; long PIN; char ch; Library obj; /chuang jian dui xiang clrscr(); coutnt -The Libraly informatio

温馨提示

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

评论

0/150

提交评论