欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++實(shí)現(xiàn)簡單的圖書管理系統(tǒng)

 更新時(shí)間:2020年04月08日 09:53:16   投稿:lijiao  
本文給大家分享的是使用C++實(shí)現(xiàn)簡單的圖書管理系統(tǒng)的代碼,本系統(tǒng)采用了面向?qū)ο蟮某绦蛟O(shè)計(jì)方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

今天再為大家介紹另一個(gè)常用的管理系統(tǒng)——圖書管理系統(tǒng),希望大家可以親自動(dòng)手實(shí)踐一下,下面就與大家一起分享我的勞動(dòng)成果。

圖書信息包括:登錄號(hào)、書名、作者名、分類號(hào)、出版單位、出版時(shí)間、價(jià)格等。試設(shè)計(jì)一圖書信息管理系統(tǒng),使之能提供以下功能:

(1)圖書信息錄入功能(圖書信息用文件保存)
(2)圖書信息瀏覽功能
(3)查詢和排序功能:(至少一種查詢方式)
        .按書名查詢
        .按作者名查詢
(4)圖書信息的刪除與修改

分享代碼如下

#include<iostream.h>
#include<conio.h> //控制臺(tái)數(shù)據(jù)輸入輸出的函數(shù)
#include<fstream.h>//文件流
#include<iomanip.h> //控制數(shù)據(jù)輸出格式
#include<string.h>

const int Maxr=100 ;//最多的讀者數(shù) 
const int Maxb=100; //最多的圖書數(shù)
const int Maxbor=5; //每位讀者最多借的書



class Book 
{//圖書類,實(shí)現(xiàn)對(duì)圖書的描述,圖書的編號(hào),書名,借出,還入等功能
private: 
int tag; //刪除標(biāo)記 1:已刪 0:未刪
int no; //圖書編號(hào)
char name[20]; //書名 
char author[20];//作者
char fenlei[20];//分類號(hào)
char cbs[20]; //出版社
int cbtime;//出版時(shí)間
double bookprice;//圖書價(jià)格
int onshelf; //是否再架 1:再架 2:已借 
public: 
Book(){;} 
char *getname()
{//獲取書名
 return name; 
} 
char *getauthorname() 
{//獲取作者名
 return author;
} 

char *getfenlei()
{//獲取分類號(hào)
 return fenlei;
}
char *getcbsname()
{//獲取出版社名 
 return cbs; 
} 
int getcbtime()
{//獲取出版時(shí)間
 return cbtime;
}
double getbookprice()
{//獲取圖書價(jià)格
 return bookprice;
}
int getno()
{//獲取圖書編號(hào)
 return no; 
}
int gettag()
{//獲取刪除標(biāo)記 
 return tag; 
}

void setname(char na[]) 
{//設(shè)置書名
 strcpy(name,na); 
} 
void setauthorname(char aa[])
{//設(shè)置作者名
strcpy(author,aa);
}
void setfenlei(char fe[])
{//設(shè)置分類號(hào)
 strcpy(fenlei,fe);
}
void setcbs(char ca[])
{//設(shè)置出版社
 strcpy(cbs,ca);
}

void setcbtime(int time) 
{//設(shè)置時(shí)間
 cbtime=time;
} 
void setbookprice(double price)
{//設(shè)置圖書價(jià)格
 bookprice=price;
}
void setonshelf(int oa) 
{
 onshelf=oa;
} 
void delbook()
{//刪除圖書
 char i;
 cout<<"確定刪除嗎?Y/N ?"<<endl;
 cin>>i;
 if(i=='y'||i=='Y')
 tag=1;
} 
void addbook(int n,char *na,char *aa,char *fe,char *ca,int time,double price,int oa) 
{//增加圖書 
 tag=0; 
 no=n; 
 strcpy(name,na);
 strcpy(author,aa);
 strcpy(cbs,ca);
 strcpy(fenlei,fe);
 cbtime=time;
 bookprice=price;
 onshelf=oa; 
} 
int borrowbook() 
{//借書操作 
 if (onshelf>0) 
 { 
 onshelf--;
 return 1; 
 } 
 return 0; 
} 
void retbook()
{//還書操作
 onshelf++; 
} 
void disp() 
{//輸出圖書 
 cout<<setw(3)<<no<<setw(10)<<name<<setw(10)<<author<<setw(10)<<fenlei<<setw(15)<<cbs<<setw(10)<<cbtime<<setw(10)<<bookprice<<setw(10)<<onshelf<<endl; 
} 
}; 


class BDatabase 
{//圖書庫類,實(shí)現(xiàn)對(duì)圖書的維護(hù),查找,刪除等 
private: 
int top; //圖書記錄指針
Book book[Maxb]; //圖書記錄
public: 
BDatabase() 
{//構(gòu)造函數(shù),將book.txt讀到book[]中 
 Book b; 
 top=-1; 
 fstream file("book.txt",ios::in); 
 while (1) 
 { 
 file.read((char *)&b,sizeof(b)); 
 if (!file) 
 break; 
 top++; 
 book[top]=b; 
 } 
 file.close(); 
} 
void clear() 
{//全刪 
 char i;
 cout<<"確定全部刪除嗎?Y/N ?"<<endl;
 cin>>i;
 if(i=='y'||i=='Y')
 top=-1; 
} 
int addbook(int n,char *na,char *aa,char *fe,char *ca,int time, double price,int oa) 
{//增加圖書 
 Book *p=query1(n); 
 if (NULL==p) 
 { 
 top++; 
 book[top].addbook(n,na,aa,fe,ca,time,price,oa); 
 return 1; 
 } 
 return 0; 
} 
Book *query1(int bookid) 
{//按編號(hào)查找圖書 
 for(int i=0;i<=top;i++) 
 if(book[i].getno()==bookid &&book[i].gettag()==0) 
 { 
 return &book[i]; 
 } 
 return NULL; 
}
Book *query2(char a[]) 
{//按書名查找圖書
 Book *e;
 int r=0;
 for(int i=0;i<=top;i++)
 if(strcmp(book[i].getname(),a)==0 &&book[i].gettag()==0) 
 { 
 if(r==0)
 cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 e=&book[i];
 e->disp();
 r++; 
 } 
 if(r==0)
 cout<<"找不到該書!"<<endl;
 return NULL; 
} 
Book *query3(char a[]) 
{//按作者查找圖書 
 Book *e;
 int r=0;
 for(int i=0;i<=top;i++) 
 if(strcmp(book[i].getauthorname(),a)==0 &&book[i].gettag()==0) 
 { 
 if(r==0)
 cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 e=&book[i];
 e->disp();
 r++; 
 } 
 if(r==0)
 cout<<"找不到該書!"<<endl;
 return NULL; 
}
Book *query4(char a[]) 
{//按出版社查找圖書 
 Book *e;
 int r=0;
 for (int i=0;i<=top;i++)
 if (strcmp(book[i].getcbsname(),a)==0 &&book[i].gettag()==0) 
 { 
 if(r==0)cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 e=&book[i];
 e->disp();
 r++; 
 }
 if(r==0)
 cout<<"找不到該書!"<<endl;
 return NULL; 
} 
void bookdata(); //圖書庫信息
void disp() 
{ 
 for(int i=0;i<=top;i++) 
 if(book[i].gettag()==0) 
 book[i].disp(); 
} 
~BDatabase() 
{//析構(gòu)函數(shù),將book[]寫到book.txt文件中 
 fstream file("book.txt",ios::out); 
 for(int i=0;i<=top;i++) 
 if(book[i].gettag()==0)
 file.write((char *)&book[i],sizeof(book[i])); 
 file.close(); 
} 
}; 
void BDatabase::bookdata() 
{ 
char choice3; 
char bname[40];//書名
char auname[40];//作者名
char bfenlei[40];//分類號(hào)
char cname[40];//出版社
int time;//出版時(shí)間
double price;//價(jià)格
char ch;
int choice4;
int bookid;
int bookod;
Book *b; 
while (choice3!='0') 
{ 
 cout<<"\n\t\t\t** 圖 書 信 息 **\n"<<endl; 
 cout<<"\t\t\t** 1.新 增 **"<<endl;
 cout<<"\t\t\t** 2.更 改 **"<<endl;
 cout<<"\t\t\t** 3.刪 除 **"<<endl;
 cout<<"\t\t\t** 4.查 找 **"<<endl;
 cout<<"\t\t\t** 5.顯 示 **"<<endl;
 cout<<"\t\t\t** 6.全 刪 **"<<endl;
 cout<<"\t\t\t** 0.返 回 **"<<endl; 
 cout<<"\t\t\t 請(qǐng)選擇:";
 cin>>choice3; 
 switch(choice3) 
 { 
 case '1': 
 cout<<"請(qǐng)輸入新書編號(hào):"; 
 cin>>bookid;
 
 b=query1(bookid); 
 if(b!=NULL) 
 { 
 cout<<"該編號(hào)已經(jīng)存在,不能添加!"<<endl;
 break; 
 }
 cout<<"請(qǐng)輸入新書書名:"; 
 cin>>bname;
 cout<<"請(qǐng)輸入新書作者名:"; 
 cin>>auname;
 cout<<"請(qǐng)輸入新書分類號(hào):";
 cin>>bfenlei;
 cout<<"請(qǐng)輸入新書出版社:"; 
 cin>>cname;
 cout<<"請(qǐng)輸入新書出版時(shí)間:";
 cin>>time;
 cout<<"請(qǐng)輸入圖書價(jià)格:";
 cin>>price;

 cout<<"請(qǐng)輸入新書數(shù)量:"; 
 cin>>bookod;
 addbook(bookid,bname,auname,bfenlei,cname,time,price,bookod);
 

 char choice2;
 {
 cout<<"\n\t\t\t** 是 否 保 存 Y/N ?**\n"<<endl;
 cout<<"\t\t\t** 1. Y 保 存 **"<<endl;
 cout<<"\t\t\t** 0. N 不 保 存 **"<<endl;
 cout<<"\t\t\t 請(qǐng) 選 擇: ";
cin>>choice2;
switch(choice2)
{
case '1':

 
 cout<<"添加圖書成功!";
 
 break;
case '0':
 
 break;
}
 }
 getch(); 
 break; 
 case '2': 
 cout<<"請(qǐng)輸入圖書編號(hào):"; 
 cin>>bookid; 
 b=query1(bookid); 
 if(b==NULL) 
 { 
 cout<<"該圖書不存在! "<<endl;
 break; 
 }
 cout<<"該圖書的信息是:"<<endl;
 cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 b->disp();
 cout<<"是否修改?( y/n ):";
 cin>>ch;
 if(ch=='y'||ch=='Y')
 {int a;
 cout<<"\n\t\t\t** 圖 書 修 改 **\n"<<endl; 
 cout<<"\t\t\t** 1.修 改 書 名 **"<<endl;
 cout<<"\t\t\t** 2.修 改 作 者 **"<<endl;
 cout<<"\t\t\t** 3.修 改 分 類 號(hào) **"<<endl;
 cout<<"\t\t\t** 4.修 改 出 版 社 **"<<endl;
 cout<<"\t\t\t** 5.修 改 出 版 時(shí) 間**"<<endl;
 cout<<"\t\t\t** 6.修 改 圖 書 價(jià) 格**"<<endl;
 cout<<"\t\t\t** 7.修 改 圖 書 數(shù) 量**"<<endl;
 cout<<"\t\t\t** 0.返 回 **"<<endl; 
 cout<<"\t\t\t 請(qǐng)選擇:";
 cin>>a; 
switch(a)
{
case 1: cout<<"請(qǐng)輸入新的書名:"; 
 cin>>bname; b->setname(bname); break;
case 2: cout<<"請(qǐng)輸入新的作者:";
 cin>>auname; b->setauthorname(auname); break;
case 3: cout<<"請(qǐng)輸入新的分類號(hào):";
 cin>>bfenlei; b->setfenlei(bfenlei); break;
case 4: cout<<"請(qǐng)輸入新書出版社:";
 cin>>cname; b->setcbs(cname); break;
case 5: cout<<"請(qǐng)輸入新書出版時(shí)間:";
 cin>>time;b->setcbtime(time); break;
case 6: cout<<"請(qǐng)輸入圖書價(jià)格:";
 cin>>price; b->setbookprice(price); break;
case 7: cout<<"請(qǐng)輸入新的存量:"; 
 cin>>bookod; b->setonshelf(bookod); break;
case 0: break;
 }
 }
 cout<<"修改圖書成功!";
 getch(); 
 break;
 case '3': 
 cout<<"請(qǐng)輸入圖書編號(hào):"; 
 cin>>bookid; 
 b=query1(bookid); 
 if(b==NULL) 
 { 
 cout<<"該圖書不存在,無法刪除!"<<endl;
 break; 
 } 
 b->delbook();
 cout<<"刪除成功!";
 getch();
 break; 
 case '4': 
 cout<<"\n\t\t\t** 1.按圖書編號(hào)查找 **"<<endl;
 cout<<"\t\t\t** 2.按圖書書名查找 **"<<endl;
 cout<<"\t\t\t** 3.按圖書作者查找 **"<<endl;
 cout<<"\t\t\t** 4.按圖書出版社查找**"<<endl;
 cout<<"\t\t\t** 0. 返 回 **"<<endl;
 cout<<"\t\t\t 請(qǐng)選擇:"; 
 cin>>choice4;
 switch(choice4)
 {
 case 1: 
 cout<<"請(qǐng)輸入圖書編號(hào):"; 
 cin>>bookid;
 b=query1(bookid);
 if(b==NULL) 
 { 
 cout<<"該圖書不存在!";
 break; 
 }
 cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 b->disp(); 
 break; 
 case 2: 
 cout<<"請(qǐng)輸入圖書書名:"; 
 cin>>bname;
 b=query2(bname);
 break;
 case 3: 
 cout<<"請(qǐng)輸入圖書作者:"; 
 cin>>auname;
 b=query3(auname);
 break;
 case 4: 
 cout<<"請(qǐng)輸入圖書出版社:"; 
 cin>>cname;
 b=query4(cname);
 break;
 case 0: 
 break;
 }
 break;
 case '5': 
 cout<<setw(3)<<"編號(hào)"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號(hào)"<<setw(15)<<"出版社"<<setw(10)<<"出版時(shí)間"<<setw(10)<<"圖書價(jià)格"<<setw(10)<<"存量"<<endl;
 disp();
 getch(); 
 break; 
 case '6': 
 clear(); 
 break; 
 default: 
 break; 
 } 
} 
}


class Reader
{//讀者的信息描述 
private: 
int tag; //刪除標(biāo)記 1表示已刪 0表示未刪 
int no; //讀者編號(hào)
char name[20]; //讀者姓名 
int borbook[Maxbor]; //所借圖書 
public: 
Reader() //構(gòu)造函數(shù)
{ ; } 
friend ostream &operator<<(ostream &output,Reader &rd)
{output<<rd.no;
output<<" ";
output<<endl;
return output;}
char *getname() 
{//獲取姓名 
 return name;

} 
int gettag() 
{//獲取刪除標(biāo)記 
 return tag; 
} 
int getno() 
{//獲取讀者編號(hào) 
 return no; 
} 
void setname(char na[]) 
{//設(shè)置姓名 
 strcpy(name,na); 
}
void delbook() 
{//設(shè)置刪除標(biāo)記 1:已刪 0:未刪 
 char i;
 cout<<"確定刪除嗎?Y/N ?"<<endl;
 cin>>i;
 if(i=='y'||i=='Y')
 tag=1; 
} 
void addreader(int n,char *na) 
{//增加讀者 
 tag=0; 
 no=n; 
 strcpy(name,na); 
 for(int i=0;i<Maxbor;i++) 
 borbook[i]=0; 
} 
void borrowbook(int bookid) 
{//借書操作 
 for(int i=0;i<Maxbor;i++) 
 { 
 if (borbook[i]==0) 
 {
 borbook[i]=bookid;
 return ; 
 } 
 } 
} 
int retbook(int bookid) 
{//還書操作 
 for(int i=0;i<Maxbor;i++) 
 { 
 if(borbook[i]==bookid) 
 { 
 borbook[i]=0;
 cout<<"還書成功!"<<endl;
 return 1; 
 } 
 }
 cout<<"未借該書,還書失敗!"<<endl;
 return 0; 
} 
void disp() 
{//讀出讀者信息
 int have=0;
 int bz=0;
 cout<<setw(5)<<no<<setw(21)<<name<<setw(15);
 for(int i=0;i<Maxbor;i++) 
 if(borbook[i]!=0)
 { 
 if(bz==0)
 {
 have=1;
 cout<<"["<<borbook[i]<<"]\t\t"<<endl; 
 bz++;
 }
 else
 {
 cout<<"\r\t\t\t\t\t""["<<borbook[i]<<"]\t\t"<<setw(15)<<endl; 
 }
 }
 if(have==0)
 cout<<"\t 還未借書"<<endl;
}
};

class RDatabase 
{//讀者類庫,實(shí)現(xiàn)建立讀者的個(gè)人資料 
private: 
int top; //讀者記錄指針 
 Reader read[Maxr]; //讀者記錄 
public: 
RDatabase() 
{//構(gòu)造函數(shù),將reader.txt讀到read[]中 
 Reader s; 
 top=-1; 
 fstream file("reader.txt",ios::in); //打開一個(gè)輸入文件
 while (1) 
 { 
 file.read((char *)&s,sizeof(s)); 
 if (!file)
 break; 
 top++; 
 read[top]=s; 
 } 
 file.close(); //關(guān)閉 reader.txt 文件
} 
void clear() 
{//刪除所有讀者信息 
 char i;
 cout<<"確定全部刪除嗎?Y/N ?"<<endl;
 cin>>i;
 if(i=='y'||i=='Y')
 top=-1; 
} 
int addreader(int n,char *na) 
{//添加讀者時(shí)先查找是否存在 
 Reader *p=queryid(n); 
 if (p==NULL)
 {
 top++; 
 read[top].addreader(n,na); 
 return 1; 
 }
 else
 cout<<"該編號(hào)已經(jīng)存在!";
 return 0; 
} 
Reader *queryid(int readerid) 
{//按讀者編號(hào)查找
 for (int i=0;i<=top;i++) 
 if (read[i].getno()==readerid&&read[i].gettag()==0) 
 { 
 return &read[i]; 
 } 
 return NULL;
}
Reader *queryname(char readername[10]) 
{//按讀者姓名查找
 for (int i=0;i<=top;i++) 
 if (strcmp(read[i].getname(),readername)==0 && read[i].gettag()==0) 
 { 
 return &read[i]; 
 } 
 return NULL; 
}  
void disp() 
{//輸出所有讀者信息 
 for(int i=0;i<=top;i++)
 if (read[i].gettag()==0)
 read[i].disp(); 
} 
void readerdata(); //讀者庫信息
~RDatabase() 
{//析構(gòu)函數(shù),將read[]寫到reader.txt文件中
 fstream file("reader.txt",ios::out); 
 for (int i=0;i<=top;i++) 
 if (read[i].gettag()==0) 
 file.write((char *)&read[i],sizeof(read[i])); 
 file.close(); 
} 
};

void RDatabase::readerdata() 
{
char choice1; 
char rname[20]; 
int readerid;
char readername[10];
int choice2;
Reader *r; 
while(choice1!='0')
{
 cout<<"\n\t\t\t** 讀 者 信 息 **\n"<<endl;
 cout<<"\t\t\t** 1. 新 增 **"<<endl;
 cout<<"\t\t\t** 2. 更 改 **"<<endl;
 cout<<"\t\t\t** 3. 刪 除 **"<<endl;
 cout<<"\t\t\t** 4. 查 找 **"<<endl;
 cout<<"\t\t\t** 5. 顯 示 **"<<endl;
 cout<<"\t\t\t** 6. 全 刪 **"<<endl;
 cout<<"\t\t\t** 0. 返 回 **"<<endl; 
 cout<<"\t\t\t 請(qǐng)選擇:";
 cin>>choice1; 
 switch(choice1) 
 { 
 case '1': 
 cout<<"請(qǐng)輸入讀者編號(hào):"; 
 cin>>readerid;
 cout<<"請(qǐng)輸入讀者姓名:"; 
 cin>>rname;
 addreader(readerid,rname);
 cout<<"添加讀者成功!"<<endl;
 getch();
 break;
 case '2': 
 cout<<"請(qǐng)輸入讀者編號(hào):"; 
 cin>>readerid; 
 r=queryid(readerid); 
 if(r==NULL) 
 { 
 cout<<"該讀者不存在! "<<endl; 
 break; 
 } 
 cout<<"請(qǐng)輸入新的姓名:"; 
 cin>>rname; 
 r->setname(rname); 
 cout<<"修改讀者成功!"<<endl;
 getch();
 break;
 case '3': 
 cout<<"請(qǐng)輸入讀者編號(hào):"; 
 cin>>readerid; 
 r=queryid(readerid); 
 if(r==NULL) 
 { 
 cout<<"該讀者不存在!" << endl; 
 break; 
 } 
 r->delbook();
 cout<<"刪除成功!"<<endl;
 getch();
 break; 
 case '4':
 cout<<"\n\t\t\t** 1.按讀者編號(hào)查找 **"<<endl;
 cout<<"\t\t\t** 2.按讀者姓名查找 **"<<endl;
 cout<<"\t\t\t** 0.返 回 **"<<endl;
 cout<<"\t\t\t 請(qǐng)選擇:"; 
 cin>>choice2;
 switch(choice2)
 {
 case 1: 
 cout<<"請(qǐng)輸入讀者編號(hào):"; 
 cin>>readerid;
 r=queryid(readerid); 
 if(r==NULL) 
 { 
 cout<<"該讀者不存在!"<< endl; 
 break; 
 }
 cout<<setw(10)<<"讀者編號(hào)"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號(hào)"<<endl;
 r->disp();
 break; 
 case 2: 
 cout<<"請(qǐng)輸入讀者姓名:"; 
 cin>>readername; 
 r=queryname(readername); 
 if(r==NULL) 
 { 
 cout<<"該讀者不存在!"<<endl;
 break; 
 }
 cout<<setw(10)<<"讀者編號(hào)"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號(hào)"<<endl;
 r->disp();
 break;
 case 0: 
 break;
 }
 break;
 case '5':
 cout<<setw(10)<<"讀者編號(hào)"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號(hào)"<<endl;
 disp();
 getch(); 
 break; 
 case '6': 
 clear();
 break; 
 default: 
 break; 
 } 
} 
}


class maindesk //實(shí)現(xiàn)程序的主界面 
{ 
 char choice5; 
 char choice2;
 double xh,mm;
 int bookid,readerid; 
 RDatabase ReaderDB; 
 Reader *r; 
 BDatabase BookDB; 
 Book *b;
public:
maindesk() {;}

int denglu()
{

int k=0;
cout<<"\n\t\t\t 歡 迎 光 臨 圖 書 館 管 理 系 統(tǒng)!"<<endl;
cout<<"\t\t\t 您 共 有 3 次 登 陸 機(jī) 會(huì)"<<endl;
while(choice2!='0')
 { ++k;
cout<<"\t\t\t ** 1. 登 錄 **"<<endl;
cout<<"\t\t\t ** 0. 退 出 **"<<endl;
cout<<"\t\t\t 請(qǐng) 選 擇: ";
cin>>choice2;
switch (choice2)
{
 
case '1':
 
 cout<<"請(qǐng)輸入學(xué)號(hào)和密碼"<<endl;
 cin>>xh>>mm;
 

 
 if((xh>=138325039)&&(xh<=138325039)&&(xh==mm))
 {
 cout<<"登錄成功"<<endl; 
 enterdesk();
 }
 
 if((xh<138325039)||(xh>138325039)||(xh!=mm))
 {cout<<"登錄失?。耗€有"<<3-k<<"次登陸機(jī)會(huì)"<<endl;
 if(k>=3)
 { 
 cout<<"您已超過登錄次數(shù)上限,系統(tǒng)自動(dòng)退出!"<<endl;
 return 1;
 
 }
 continue;
 }
 break;

case '0':
 break;}
return 1;
}
return 0;
}

 void enterdesk()
 {
while(choice5!='0') 
{ 
 cout<<"\n\t\t\t**** 圖 書 管 理 系 統(tǒng)****\n\n"; 
 cout<<"\t\t\t** 1.圖 書 信 息 **"<<endl;
 cout<<"\t\t\t** 2.讀 者 信 息 **"<<endl;
 cout<<"\t\t\t** 3.借 閱 圖 書 **"<<endl;
 cout<<"\t\t\t** 4.歸 還 圖 書 **"<<endl;
 cout<<"\t\t\t** 0. 退 出 **"<<endl; 
 cout<<"\t\t\t 請(qǐng)選擇:";
 cin>>choice5; 
 switch (choice5) 
 { 
 
 
 case '1': 
 BookDB.bookdata(); 
 break; 
 case '2': 
 ReaderDB.readerdata(); 
 break; 
 case '3':
 cout<<"\t\t\t\t借書操作"<<endl;
 cout<<"請(qǐng)輸入借書讀者編號(hào):"; 
 cin>>readerid;
 r=ReaderDB.queryid(readerid); 
 if(NULL==r) 
 {//按編號(hào)查找是否有該讀者 
 cout<<"不存在該讀者,不能借書!"<<endl;
 break; 
 } 
 cout<<"請(qǐng)輸入要借圖書編號(hào):"; 
 cin>>bookid; 
 b=BookDB.query1(bookid); 
 if(b==NULL) 
 {//按編號(hào)查找是否有該圖書 
 cout<<"不存在該圖書,不能借書!"<<endl;
 break; 
 } 
 if(b->borrowbook()==0) 
 { 
 cout<<"該圖書已借完,不能借書!"<<endl;
 break; 
 }
 cout<<"讀者借書成功!"<<endl;
 r->borrowbook(b->getno());
 break; 
 case '4': 
 cout<<"\t\t\t\t還書操作"<<endl;
 cout<<"請(qǐng)輸入還書讀者編號(hào):"; 
 cin>>readerid;
 r=ReaderDB.queryid(readerid);
 if(r==NULL) 
 { 
 cout<<"不存在該讀者,不能還書"<<endl;
 break; 
 } 
 cout<<"請(qǐng)輸入要?dú)w還圖書編號(hào):"; 
 cin>>bookid; 
 b=BookDB.query1(bookid); 
 if(b==NULL) 
 {
 cout<<"不存在該圖書,不能還書"<<endl; 
 break; 
 }
 b->retbook(); 
 r->retbook(b->getno());
 break;
 case '0':
 break;
 default: 
 
 break; 
 } 
} 
}
};
void main() //主函數(shù)
{
 maindesk yourDesk;
 if(yourDesk.denglu())
 cout<<"\t\t 謝 謝 使 用 , 再 見 !"<<endl;

}

運(yùn)行效果圖:

關(guān)于管理系統(tǒng)的更多內(nèi)容請(qǐng)點(diǎn)擊《管理系統(tǒng)專題》進(jìn)行學(xué)習(xí)

以上就是本文的全部內(nèi)容,希望大家可以喜歡,抓緊動(dòng)手實(shí)現(xiàn)吧

相關(guān)文章

  • 關(guān)于C++使用指針 堆和棧的區(qū)別分析

    關(guān)于C++使用指針 堆和棧的區(qū)別分析

    本篇文章小編為大家介紹,關(guān)于C++使用指針 堆和棧的區(qū)別分析。需要的朋友參考下
    2013-04-04
  • 深入了解C++ 結(jié)構(gòu)體(struct)與共用體(union)

    深入了解C++ 結(jié)構(gòu)體(struct)與共用體(union)

    這篇文章主要介紹了C++ 結(jié)構(gòu)體與共用體的的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)c++,感興趣的朋友可以了解下
    2020-08-08
  • 深入學(xué)習(xí)C語言mmap和shm*的使用方法技巧

    深入學(xué)習(xí)C語言mmap和shm*的使用方法技巧

    本文將詳細(xì)介紹mmap和shm的工作原理,包括它們?cè)趦?nèi)存映射和共享內(nèi)存方面的優(yōu)勢(shì)和適用場(chǎng)景,同時(shí),文章還會(huì)分享一些使用mmap和shm的技巧和經(jīng)驗(yàn),以幫助讀者優(yōu)化并提高程序性能,使你能夠在實(shí)際項(xiàng)目中更好地利用這些技術(shù)來加速數(shù)據(jù)共享和多線程應(yīng)用
    2023-10-10
  • 基于C++全局變量的聲明與定義的詳解

    基于C++全局變量的聲明與定義的詳解

    本篇文章是對(duì)C++全局變量的聲明與定義進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • C++命名空間域的實(shí)現(xiàn)示例

    C++命名空間域的實(shí)現(xiàn)示例

    命名空間域就是一個(gè)獨(dú)立的空間外面不能直接調(diào)用該空間域只能用訪問限定符指定訪問該空間域,本文主要介紹了C++命名空間域的實(shí)現(xiàn)示例,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-01-01
  • C++詳解默認(rèn)參數(shù)的構(gòu)造函數(shù)及簡單實(shí)例代碼

    C++詳解默認(rèn)參數(shù)的構(gòu)造函數(shù)及簡單實(shí)例代碼

    這篇文章主要介紹了 C++詳解默認(rèn)參數(shù)的構(gòu)造函數(shù)及簡單實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • C++函數(shù)重載的細(xì)節(jié)圖文詳解

    C++函數(shù)重載的細(xì)節(jié)圖文詳解

    函數(shù)重載即函數(shù)名相同,函數(shù)形參列表不同(函數(shù)特征標(biāo)不同)的一類函數(shù)稱為函數(shù)重載,下面這篇文章主要給大家介紹了關(guān)于C++函數(shù)重載的相關(guān)資料,需要的朋友可以參考下
    2022-12-12
  • C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(文件版)

    C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(文件版)

    這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • Qt線程池QThreadPool的使用詳解

    Qt線程池QThreadPool的使用詳解

    本文主要介紹了Qt線程池QThreadPool的使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • 你真的知道C++對(duì)象大小嗎?

    你真的知道C++對(duì)象大小嗎?

    這篇文章主要給大家介紹了關(guān)于C++對(duì)象大小的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01

最新評(píng)論