本文实例为大家分享了c++版图书管理系统的具体代码,供大家参考,具体内容如下
图书管理系统源码由两部分组成,第一部分book.h头文件,第二部分book.cpp源文件。复制代码时需注意将book.h文件的源码单独放在一个一个文件里,文件名必须为book.h。源码文件也需放在一个单独的.cpp文件里。
book.h头文件
#include<iostr测试智商的测试题免费eam>#include<string>#include<stdlib.h>#include<conio.h>using namespace std;//会员类class vip{public: int vnum; //会员号 string name; //会员姓名 int num; //图书编号 string bookname; //书名 string author; //作者 string press; //出版社 vip *next; //指针};//图书结点类class node{public: int num; //图书编号 string bookname; //书名 string author; //作者 string press; //出版社 node *next; //指针};vip vip[100];node book[100];void add(); //增加图书函数void output(node p); //输出图书信息函数int lookupbook(); //通过书名查找void lookupauthor(); //通过作者名查找int lookupnum(); //通过编号查找void lookuppress(); //通过出版社查找void addvip(); //增加会员函数void outputvip(vip s); //输出会员信息函数int lookupnumvip(); //按编号查询会员void lookupnamevip(); //按会员姓名查找会员void deletevipbook(); //删除会员借书信息void delete(); //删除会员函数void query(); //根据会员编号查询借书信息void return(); //还书函数void borrow(); //图书借阅函数void index(); //首页void bookinterface(); //图书管理界面void vipinterface(); //会员管理界面void deletebook(); //删除图书函数void lookupbookin(); //图书查询页面void lookupvipin();//会员查询页面
book.cpp源文件
#include"book.h" int main(){ index(); //首页函数 return 0;}//增加图书函数void add(){ for(int i=0;i<100;i++){ if(book[i].num==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入图书编号:"; cin>>book[i].num; cout<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入书名:"; cin>>book[i].bookname; cout<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入作者:"; cin>>book[i].author; cout<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入出版社:"; cin>>book[i].press; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"图书添加成功"<<"\n"<<endl; break; } } return;}//删除图书函数void deletebook(){ int b=lookupnum(); book[b].author='\0'; book[b].bookname='\0'; book[b].num=0; book[b].press='\0'; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"图书删除成功"<<endl;}//输出图书信息函数void output(int b){ cout<<"\t"<<"\t"<<"\t"<<"\t"<<"图书编号:"<<book[b].num<<" 书名:"<<book[b].bookname<<" 作者:"<<book[b].author<<" 出版社:"<<book[b].press<<"\n"<<endl;}//通过书名查找int lookupbook(){ int j=0; string bookname; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入书名:"; cin>>bookname; for(int i=0;i<100;i++){ if(book[i].bookname==bookname){ j=1; output(i); return i; } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该图书"<<"\n"<<endl; } return 1000;}//通过作者名查找void lookupauthor(){ int j=0; string author; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入作者姓名:"; cin>>author; for(int i=0;i<100;i++){ if(book[i].author==author){ j=1; output(i); } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该图书"<<"\n"<<endl; }}//通过编号查找int lookupnum(){ int j=0; int nuru元素m; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入图书编号:"; cin>>num; for(int i=0;i<100;i++){ if(book[i].num==num){ j=1; output(i); return i; } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该图书"<<"\n"<<endl; } return 1000;}//通过出版社查找void lookuppress(){ int j=0; string press; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入图书出版社:"; cin>>press; for(int i=0;i<100;i++){ if(book[i].press==press){ j=1; output(i); break; } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该图书"<<"\n"<<endl; }}//增加会员函数void addvip(){ for(int i=0;i<100;i++){ if(vip[i].vnum==0){ cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入会员编号:"; cin>>vip[i].vnum; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入会员名:"; cin>>vip[i].name; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"会员添加成功"<<"\n"<<endl; break; } }}//输出会员信息函数void outputvip(int s){ cout<<"\t"<<"\t"<<"\t"<<"\t"<<"会员编号:"<<vip[s].vnum<<" 会员姓名:"<<vip[s].name<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"图书编号:"<<vip[s].num<<" 书名:"<<vip[s].bookname<<" 作者:"<<vip[s].author<<" 出版社:"<<vip[s].press<<endl;}//按编号查询会员int lookupnumvip(){ int j=0; int num; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入会员编号:"; cin>>num; for(int i=0;i<100;i++){ if(vip[i].vnum==num){ outputvip(i); j=1; return i; } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该会员"<<"\n"<<endl; } return 1000;}//按会员姓名查找会员void lookupnamevip(){ int j=0; string name; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入会员姓名:"; cin>>name; for(int i=0;i<100;i++){ if(vip[i].name==name){ j=1; outputvip(i); break; } } if(j==0){ cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"没有该会员"<<"\n"<<endl; }}//删除会员借书信息void deletevipbook(){ int s=lookupnumvip(); vip[s].author='\0'; vip[s].bookname='\0'; vip[s].num=0; vip[s].press='\0';}//删除会员函数void delete(){ int s=lookupnumvip(); vip[s].name='\0'; vip[s].vnum=0; vip[s].author='\0'; vip[s].bookname='\0'; vip[s].num=0; vip[s].press='\0'; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"会员删除成功"<<endl;}//根据会员编号查询借书信息void query(){ lookupnumvip();}//还书函数void return(){ deletevipbook(); cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"图书归还成功"<<"\n"<<endl;}//图书借阅函数void borrow(){ int b=lookupbook(); int s=lookupnumvip(); vip[s].bookname=book[b].bookname; vip[s].author=book[b].author; vip[s].num=book[b].num; vip[s].press=book[b].press; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"借书成功"<<"\n"<<endl;}//首页void index(){ int i; system("cls"); cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 图书管理系统 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 1、图书管理 2、会员管理 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请选择:"; cin>>i; switch(i){ ca 1: bookinterface(); break; ca 2: vipinterface(); break; default: cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入1或2"<<"\n"<<endl; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); index(); }}//图书管理界面void bookinterface(){ system("cls"); int i; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 图书管理系统 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 1、增加图书 2、查询图书 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 3、图书借阅 4、图书归还 ****"<<endl; cout<<"\t"<<"\t"<东周列国传;<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 5、删除图书 6、返回首页 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请选择:"; cin>>i; switch(i){ ca 1: add(); //增加图书函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); bookinterface(); break; ca 2: lookupbookin(); //图书查询页面 break; ca 3: borrow(); //图书借阅函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); bookinterface(); break; ca 4: return(); //还书函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); bookinterface(); break; ca 5: deletebook(); //删除图书函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); bookinterface(); break; ca 6: index(); default: cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入对应编号"<<"\n"<<endl; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); bookinterface(); }}//会员管理界面void vipinterface(){ system("cls"); int i; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 图书管理系统 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 1、增加会员 2、查询会员 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 3、借书信息 4、删除会员 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"站在巨人肩上<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 5、返回首页 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请选择:"; cin>>i; switch(i){ ca 1: addvip(); //增加会员函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); vipinterface(); break; ca 2: lookupvipin(); //会员查询页面 break; ca 3: query(); //根据会员编号查询借书信息 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); vipinterface(); break; ca 4: delete(); //删除会员函数 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); vipinterface(); break; ca 5: index(); break; default: cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入对应编号"<<"\n"<<endl; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); vipinterface(); }}//图书查询页面void lookupbookin(){ system("cls"); int i; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"**************************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 图书管理系统 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**************************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 1、图书编号查询 2、书名查询 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 3、图书作者查询 4、图书出版社查询 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 5、返回上一页 6、返回首页 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**************************************************"<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请选择:"; cin>>i; switch(i){ ca 1: lookupnum(); //通过编号查找 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupbookin(); break; ca 2: lookupbook(); //通过书名查找 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupbookin(); break; ca 3: lookupauthor(); //通过作者名查找 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupbookin(); break; ca 4: lookuppress(); //通过出版社查找 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupbookin(); break; ca 5: bookinterface(); //图书管理界面 break; ca 6: index(); break; default: cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入对应编号"<<"\n"<<end助学金申请书800字l; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupbookin(); }}//会员查询页面void lookupvipin(){ int i; system("cls"); cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 图书管理系统 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 1、通过编号查找会员 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 2、通过姓名查找会员 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 3、返回上一页 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"**** 4、返回首页 ****"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"****************************************"<<"\n"<<endl; cout<<"\t"<<"\t"<<"\t"<<"\t"<<"请选择:"; cin>>i; switch(i){ ca 1: lookupnumvip(); //按编号查询会员 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupvipin(); break; ca 2: lookupnamevip(); //按会员姓名查找会员 cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupvipin(); break; ca 3: vipinterface(); //会员管理界面 break; ca 4: index(); break; default: cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"<<"请输入对应编号"<<"\n"<<endl; cout<<"\n"<<"\t"<<"\t"<<"\t"<<"\t"; system("pau"); lookupvipin(); }}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持www.887551.com。
本文发布于:2023-04-06 03:15:48,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/76cf83b62b40538f6a8eb960a1765610.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:C++版图书管理系统.doc
本文 PDF 下载地址:C++版图书管理系统.pdf
留言与评论(共有 0 条评论) |