日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

C++實現圖書管理系統源碼_C 語言

作者:往事五塊兩毛一 ? 更新時間: 2022-05-16 編程語言

本文實例為大家分享了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

欄目分類
最近更新