網站首頁 編程語言 正文
本文實例為大家分享了C++實現圖書管理系統的具體代碼,供大家參考,具體內容如下
直接上代碼
#include#include #include #include #include #include #include using namespace std; class Books { ?? ?private: ?? ??? ?string bookname; //書名? ?? ??? ?string writername; ?//作者名 ?? ??? ?string publishname; ?//出版社 ?? ??? ?int num; ?//圖書數量?? ??? ? ?? ??? ?string sname; // 學生姓名? ?? ??? ?int number; // 學生賬號? ?? ??? ?static int length; //靜態數據成員? ?? ??? ?int zf; ?//借閱圖書數量? ?? ?public: ?? ??? ?Books(string b="1",string w="2",string p="3",int n=0,int f=0);?? ?//聲明構造函數?? ? ?? ??? ?void maintain(Books *m); // 信息的增刪改 ?? ??? ?void demand(Books *m); // 信息查詢 ?? ??? ?void bore(Books *m); //圖書的借,還 ?? ??? ?void stat(Books *m); //信息統計和顯示 ?? ??? ?void jssc(); ?// 輸出格式函數? ?? ??? ?void sc(Books *p); //輸出格式函數? ?? ??? ?void rest(Books *m); //統計圖書受歡迎程度 ?? ??? ?void storage(Books *m); //信息保存 ?? ??? ?void OpenFile(); //打開文件? ?? ??? ?void quit(); //退出系統?? ? }; int Books::length=5; Books::Books(string b,string w,string p,int n,int f)//定義構造函數? { ?? ?bookname=b; ?? ?writername=w; ?? ?publishname=p; ?? ?num=n; ?? ?zf=f; } void Books::maintain(Books *m)//圖書的增刪改? { ? ? int i=0; ?? ?int j; ?? ?m[i].sc(m); ?? ? ?? ?B:cout<<"添加圖書請按1,刪除圖書請按2,修改圖書信息請按3,退出請按0"< >a;?? ??? ? ?? ? ?? ?if(a==1) ?//添加圖書? ?? ?{?? ??? ? ?? ??? ?A:cout<<"請依次輸入書名,作者,出版社,圖書數量"< >(*(m+length)).bookname>>(*(m+length)).writername>>(*(m+length)).publishname>>(*(m+length)).num; ?? ??? ?length++; ?? ??? ? ?? ??? ?cout<<"繼續添加請按1,執行其他操作請按2"< >b; ?? ??? ?if(b==1) ?? ??? ? ?goto A; ?? ??? ?else ?? ??? ? ?goto B;?? ??? ? ?? ?} ?? ? ?? ?if(a==2) ? ?//刪除圖書? ?? ?{ ?? ??? ?C:cout<<"請輸入要刪除的書名" < >a; ?? ? ? ?i=0; ?? ? ? ? ?? ? ? ?while(i >c; ?? ??? ?if(c==1) ?? ??? ? ?goto C; ?? ??? ?else ?? ??? ? ?goto B; ?? ?}? ?? ? ?? ?if(a==3) ? //修改圖書信息? ?? ?{ ?? ??? ?D:cout<<"請輸入要修改的書名" < >b; ?? ??? ?i=0; ?? ? ? ? ?? ??? ?while(i >m[i].bookname>>m[i].writername>>m[i].publishname>>m[i].num;?? ? ?? ? ?? ?? ??? ?cout<<"繼續修改請按1,執行其他操作請按2"< >d; ?? ??? ?if(d==1) ?? ??? ? ?goto D; ?? ??? ?else ?? ??? ? ?goto B; ?? ?}? ?? ? ?? ?if(a==0) ?? ?{ ?? ? ? ?goto E;?? ? ? ? } ?? ?E:; } void Books::demand(Books *m)//查找圖書? { ? ? cout<<"請輸入要查找的書名" < >b; ?? ?int i=0; ?? ? ? ? ?? ?while(i >d; ?? ?if(d==1) ?? ? ?goto F; ?? ?else ?? ? ?goto G; ?? ?G:; }? void Books::bore(Books *m) ? //借書還書? { ?? ?int i; ?? ?A:cout<<"借書請按1,還書請按2,退出請按0:"< >t; ?? ? ?? ?if(t==1) ? ? {? ?? ? ? ?B:cout<<"請輸入要借的書名和數量:" < >a; ?? ? ? ?cin>>s;? ?? ? ? ?int i=0; ?? ? ? ?while(i =0) ?? ??? ? ? ?{ ?? ??? ??? ? ? ?m[i].num=m[i].num-s; ?? ??? ??? ? ? ?cout<<"請輸入借書人姓名及學號:" < >b; ?? ??? ? ? ? ? ?cin>>c; ?? ??? ? ? ? ? ?m[i].sname=b; ?? ??? ? ? ? ? ?m[i].number=c; ?? ??? ? ? ? ? ?m[i].zf=s; ?? ??? ??? ?} ?? ??? ??? ?else ?? ??? ??? ?{ ?? ?? ??? ? ? ??? ?cout<<"圖書數量不夠"< >g; ? ? ?? ?if(g==1) ? ? ? ?? ? ?goto B; ? ? ?? ?else ? ? ?? ? ?goto A; ? ? } ? ?? ??? ?if(t==2) ?? ?{ ?? ??? ?C:cout<<"請輸入要還的書名和數量:" < >d; ?? ? ? ?cin>>e;? ?? ? ? ?i=0; ?? ? ? ?while(i >f; ?? ??? ?if(f==1) ?? ??? ? ?goto C; ?? ??? ?else ?? ??? ? ?goto A;? ? ? } ?? ? ?? ?if(t==0) ?? ?{ ?? ? ? ?goto E;?? ? ? ? } ?? ?E:; }? void Books::stat(Books *m) { ?? ?int i=0; ?? ?int n=0; ?? ?int fsum=0;//被借閱數量? ?? ?int sum=0;//剩余書籍總數量 ?? ?for(i=0;i >t; ?? ?if(t==1) ?? ?{ ?? ??? ? ?? ?AAA:cout<<"輸入賬號名:"; ?? ??? ?cin>>sber;? ?? ??? ?elem[i]=sber; ?? ??? ?for(v=0;v>t; ?? ??? ?if(t==1)? ?? ??? ?{ ?? ??? ??? ?system("cls"); ?? ??? ??? ?goto AAA; ?? ? ??? ?} ?? ? ? ?else ?? ??? ?{ ?? ??? ? ??? ?system("cls"); ?? ??? ?}?? ? ?? ?} ? ?? ? ?? ?cout<<"執行登錄請按2,退出請按3:"; ?//登錄? ?? ?cin>>t; ?? ?if(t==2)? ?? ?{?? ??? ? ?? ? ? ?cout<<"輸入賬號:"; ?? ? ? ?cin>>s2; ?? ? ? ?for(j=0;j<=i;j++) ?? ? ? ?{ ?? ? ?? ? ? ?if(elem[j]==s2)? ?? ? ?? ? ? ?{ ?? ? ?? ??? ? ? ?k=j; //k為位序? ?? ? ?? ? ??? ? ? ?goto BBB; ?? ? ?? ??? ?} ?? ? ? ?} ?? ? ? ?cout<<"賬號不存在,退出!"; ?? ? ?? ?exit(0); ?? ?? ?? ?BBB:cout<<"輸入密碼:";? ?? ? ? ?for(x=0;x<3;x++)? ?? ? ? ?{ ?? ??? ??? ?h=0; ?? ? ? ? ??? ?while(h<10&&(c[h]=getch())!='\r')? ?? ??? ? ? ?{ ?? ??? ? ? ?? ? ? ?d[h]=c[h]; ?? ??? ? ??? ? ? ?h++; ?? ??? ? ??? ? ? ?cout<<"*"; ?? ??? ? ? ?} ?? ??? ? ? ?s1=d; ? ? ?//字符數組賦值給字符串? ?? ??? ? ? ?if(s[k]==s1)? ?? ??? ? ? ?{ ?? ??? ? ??? ? ? ?cout<<"登陸成功"; ?? ??? ? ??? ? ? ?x=x-1; ?? ??? ??? ? ? ?break; ?? ??? ? ? ?} ?? ??? ? ? ?else ?? ??? ? ? ?{ ?? ??? ? ??? ? ? ?cout< >z; ?? ?switch(z) ?? ?{ ?? ? ?case 1: book[0].maintain(m); break; ?? ? ?case 2: book[0].demand(m); break; ?? ? ?case 3: book[0].bore(m); break; ?? ? ?case 4: book[0].stat(m); break; ?? ? ?case 5: book[0].rest(m); break;? ?? ? ?case 6: book[0].storage(m);break; ?? ? ?case 7: book[0].OpenFile();break; ?? ? ?case 8: exit(1);break; ?? ?}? ?? ?cout<<"繼續請按y或Y:"; ?? ?cin>>ch;?? ? ? ? } ?? ?return 0; }
運行截圖
原文鏈接:https://blog.csdn.net/qq_43641475/article/details/103576677
相關推薦
- 2022-07-03 golang defer,func()閉包,panic ,recover,contex
- 2023-04-03 python中super().__init__()作用詳解_python
- 2023-06-16 Qt6實現調用攝像頭并顯示畫面_C 語言
- 2022-01-30 取消radio的選中狀態
- 2022-09-14 Python安裝xarray庫讀取.nc文件的詳細步驟_python
- 2022-12-21 Swift使用enum抹平數組元素差異實例詳解_Swift
- 2022-04-01 k8s報錯error: You must be logged in to the server (U
- 2022-12-10 深入了解C++11中promise和future的使用_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支