问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

图书信息管理系统设计c程序设计

发布网友 发布时间:2022-05-05 08:55

我来回答

5个回答

热心网友 时间:2023-10-26 03:27

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>//输入/输出文件流类
using namespace std;
const int Maxr=100;//最多的读者
const int Maxb=100;//最多的图书
const int Maxbor=5;//每位读者最多借五本书
//读者类,实现对读者的信息的描述

class Reader
{
private:
int tag; //删除标记 1:已删 0:未删
int no; //读者编号
char name[10]; //读者姓名
int borbook[Maxbor];//所借图书
public:
Reader() {}
char *getname() {return name;} //获取姓名
int gettag() {return tag;} //获取删除标记
int getno() {return no;} //获取读者编号
void setname(char na[]) //设置姓名
{
strcpy(name,na);

}
void delbook(){ tag=1; }//设置删除标记 1:已删 0:未删
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;
return 1;

}
}
return 0;
}
void disp()//读出读者信息
{
cout << setw(5) << no <<setw(10) << name<<"借书编号:[";
for(int i=0;i<Maxbor;i++)
if(borbook[i]!=0)
cout << borbook[i] << "|";
cout << "]"<<endl;

}
};
//读者类库,实现建立读者的个人资料
class RDatabase
{
private:
int top; //读者记录指针
Reader read[Maxr];//读者记录
public:
RDatabase() //构造函数,将reader.txt读到read[]中
{
Reader s;
top=-1;
fstream file("reader.txt",ios::in);//打开一个输入文件
while (1)
{
file.read((char *)&s,sizeof(s));
if (!file)break;
top++;
read[top]=s;
}
file.close(); //关闭 reader.txt
}
void clear()//删除所有读者信息
{
top=-1;
}
int addreader(int n,char *na)//添加读者时先查找是否存在
{
Reader *p=query(n);
if (p==NULL)
{
top++;
read[top].addreader(n,na);
return 1;
}
return 0;
}
Reader *query(int readerid)//按编号查找
{
for (int i=0;i<=top;i++)
if (read[i].getno()==readerid &&
read[i].gettag()==0)
{
return &read[i];
}
return NULL;
}
void disp() //输出所有读者信息
{
for (int i=0;i<=top;i++)
read[i].disp();
}
void readerdata();//读者库维护
~RDatabase() //析构函数,将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 choice;
char rname[20];
int readerid;
Reader *r;
while (choice!='0')
{
cout <<"\n\n\t\t\t读 者 维 护\n\n\n\t\t 1 新 增\n\n\t\t 2 更 改\n\n\t\t 3 删 除\n\n\t\t 4 查 找\n\n\t\t 5 显 示\n\n\t\t 6 全 删\n\n\t\t 0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入读者编号:";
cin >> readerid;
cout << "输入读者姓名:";
cin >> rname;
addreader (readerid,rname);
break;
case '2':
cout << "输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout << " 该读者不存在 "<<endl;
break;
}
cout << "输入新的姓名:";
cin >> rname;
r->setname(rname);
break;
case '3':
cout << " 输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<" 该读者不存在" << endl;
break;
}
r->delbook();
break;
case '4':
cout << "读入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<"该读者不存在"<< endl;
break;
}
r->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:cout<<"输入错误,请从新输入:";break;
}
}
}

//图书类,实现对图书的描述,图书的编号,书名,借出,还入等
class Book
{
private:
int tag;//删除标记 1:已删 0:未删
int no;//图书编号
char name[20];//书名
int onshelf;//是否再架 1:再架 2:已借
public:
Book(){}
char *getname() { return name; }//获取姓名
int getno(){ return no; }//获取图书编号
int gettag(){ return tag; }//获取删除标记
void setname(char na[])//设置书名
{
strcpy(name,na);
}
void delbook(){ tag=1;}//删除图书
void addbook(int n,char *na)//增加图书
{
tag=0;
no=n;
strcpy(name,na);
onshelf=1;
}
int borrowbook()//借书操作
{
if (onshelf==1)
{
onshelf=0;
return 1;
}
return 0;
}
void retbook()//还书操作
{
onshelf=1;
}
void disp()//输出图书
{
cout << setw(6) << no << setw(18) << name << setw(10)
<<(onshelf==1? "在架":"已借") <<endl;
}
};

//图书库类,实现对图书的维护,查找,删除等
class BDatabase
{
private:
int top; //图*录指针
Book book[Maxb]; //图*录
public:
BDatabase()//构造函数,将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()//全删
{
top=-1;
}
int addbook(int n,char *na)//增加图书
{
Book *p=query(n);
if (NULL==p)
{
top++;
book[top].addbook(n,na);
return 1;
}
return 0;
}
Book *query(int bookid)//查找图书
{
for (int i=0;i<=top;i++)
if (book[i].getno()==bookid &&book[i].gettag()==0)
{
return &book[i];
}
return NULL;
}
void bookdata();//图书库维护
void disp()
{
for (int i=0;i<=top;i++)
if (book[i].gettag()==0)
book[i].disp();
}
~BDatabase()//析构函数,将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 choice;
char bname[40];
int bookid;
Book *b;
while (choice!='0')
{
cout <<"\n\n\n\t\t\t图 书 维 护 "<<endl<<endl;
cout<<"\t\t1 新 增\n \t\t2 更 改\n\t\t3 删 除\n\t\t4 查 找\n\t\t5 显 示\n\t\t6 全 删\n\t\t0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入图书编号:"<<endl;
cin >> bookid;
cout << "输入图书书名:"<<endl;
cin >> bname;
addbook(bookid,bname);
break;
case '2':
cout << "输入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout << " 该图书不存在 "<<endl;
break;
}
cout << "输入新的书名:"<<endl;
cin >> bname;
b->setname(bname);
break;
case '3':
cout <<" 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在" << endl;
break;
}
b->delbook();
break;
case '4':
cout << " 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在"<< endl;
break;
}
b->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:cout<<"输入错误,请从新输入:";
}
}
}
//main() 函数的实现,程序的主界面的引导
void main()
{
char choice;
int bookid,readerid;
RDatabase ReaderDB;
Reader *r;
BDatabase BookDB;
Book *b;
while(choice!='0')
{
cout <<endl<<endl<<"\t\t\t 图 书 管 理 系 统\n\n\n";

cout <<"\t\t\t1 借 书\n\n\t\t\t2 还 书 \n\n\t\t\t3 图 书 维 护\n\n\t\t\t4 读 者 维 护\n\n\t\t\t0 离 开"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout <<" 借书 读者编号:";
cin >>readerid;
cout <<" 图书编号: ";
cin >>bookid;
r=ReaderDB.query(readerid);//按编号查找
if (NULL==r)
{
cout <<" 不存在该读者,不能借书"<< endl;
break;
}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能借书"<< endl;
break;
}
if (b->borrowbook()==0)
{
cout << " 该图书已借出,不能借书"<< endl;
break;
}
r->borrowbook(b->getno());
break;
case '2':
cout<<"还书\n 读者编号:";
cin >>readerid;
cout << " 图书编号:";
cin >>bookid;
r=ReaderDB.query(readerid);
if (r==NULL)
{
cout <<" 不存在该读者,不能还书" << endl;
break;
}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能还书" <<endl;
break;
}
b->retbook();
r->retbook(b->getno());
break;
case '3':
BookDB.bookdata();
break;
case '4':
ReaderDB.readerdata();
break;
default:cout<<"输入错误,请从新输入:";
}
}
}

热心网友 时间:2023-10-26 03:28

#include<iostream.h>
#include<string.h>
#include<stdio.h>
const n=100;
int m=0;
class Book
{
private:
unsigned long no;
char name[35]; //书名
char author[20];//作者
char cbs[20]; //出版社
char key[5][20];//关键词
int onshelf; //是否再架 1:再架 2:已借
char lender[20];
unsigned long phone;
int y,m,d;
public:
void init();//初始化
friend void output();
friend void output_lend();
friend void way_1();
friend void way_2();
friend void way_3();
friend void loan();
friend void send();
};
Book p[n];
Book *k=p;
void Book::init()//初始化
{cout<<"Input the book NO!"<<endl;
cin>>no;
cout<<"Input the book name!"<<endl;
gets(name);
cout<<"Input the author!"<<endl;
gets(author);
cout<<"Input the publishing house!"<<endl;
gets(cbs);
for(int i=0;i<5;i++)
{cout<<"The "<<i+1<<" keyword:"<<endl;
gets(key[i]);
cout<<endl;
}
cout<<"Iuput the status!(0 or 1)"<<endl;
cin>>onshelf;
}
void demand()//查询图书
{int choose;
cout<<"Choose which kind of inquires the way?"<<endl;
cout<<"[1]Readers can provide the book name by queries!"<<endl;
cout<<"[2]Readers can by asking book NO query!"<<endl;
cout<<"[3]Readers can provide the keyword by queries!"<<endl;
cout<<"[4] EXIT!"<<endl;
cin>>choose;
if(choose==1) way_1();
else if(choose==2) way_2();
else if(choose==3) way_3();
else return;
}
void addbook()
{char y;
for(;;)
{m++;
k->init();
k++;
cout<<"------------Are you continue?---------"<<endl;
cin>>y;
if(y=='n') break;
}
}
void output()//输出信息
{
cout<<"-----------Output the DATE!---------"<<endl;
for(int i=0;i<m;i++)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl<<endl;}
}
void output_lend()
{cout<<"----------Output the book had been lend!---------"<<endl;
for(int i=0;i<m;i++)
{if(p[i].onshelf==1)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;
cout<<"KEYWORD:"<<p[i].key[0]<<" "<<p[i].key[1]<<" "<<p[i].key[2]<<" "<<p[i].key[3]<<" "<<p[i].key[4]<<endl;
cout<<"LENDER:"<<p[i].lender<<endl;
cout<<"PHONE:"<<p[i].phone<<endl;
cout<<"LEND DATE:"<<p[i].y<<" " <<p[i].m<<" " <<p[i].d<<endl<<endl;}
}}
void way_1()
{ char nam[35];
cout<<"-----------Input the book name !---------"<<endl;
gets(nam);
for(int i=0;i<m;i++)
{if(strcmp(p[i].name,nam)==0)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;return;
}
}
cout<<"NOT FIND!"<<endl;return;
}
void way_2()
{unsigned long na;
cout<<"Input the book NO !"<<endl;
cin>>na;
for(int i=0;i<m;i++)
{if(p[i].no==na)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;return;
}
}
cout<<"Input error!"<<endl;
}
void way_3()
{char keyword[30];
cout<<"------------Input the keyword !-------------"<<endl;
cin>>keyword;
for(int i=0;i<m;i++)
for(int j=0;j<5;j++)
if(strcmp(p[i].key[j],keyword)==0)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;}
}

void loan()//借书功能
{char y;
unsigned long n;
cout<<"Input the book NO!"<<endl;
cin>>n;
for(int i=0;i<m;i++)
if(n==p[i].no)
{if(p[i].onshelf==0)
{{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;
cout<<"Are you want to lend the book?"<<endl;
cin>>y;}
if(y=='y')
{cout<<"Registration borrowing the people's names!"<<endl;
cin>>p[i].lender;
cout<<"Registration lending people's telephone number!"<<endl;
cin>>p[i].phone;
cout<<"Registration lending date!"<<endl;
cin>>p[i].y>>p[i].m>>p[i].d;
p[i].onshelf=1;
cout<<"Borrow success!"<<endl;
return;
}}
}
cout<<"Input error!"<<endl;
return;
}
void send()//还书功能
{unsigned long n;
cout<<"Input the book NO!"<<endl;
cin>>n;
for(int i=0;i<m;i++)
{if(n==p[i].no)
{if(p[i].onshelf==1)
{p[i].onshelf=0;
cout<<"retuen success!"<<endl;return;}
}
}
cout<<"Input error!"<<endl;return;}

void main()
{ char y;
for(;;)
{int ch;
cout<<"---------------Library management system-----------------"<<endl;
cout<<"-----------------------MENU------------------------"<<endl;
cout<<"----[1] Add books------------------"<<endl;
cout<<"----[2] check books----------------"<<endl;
cout<<"----[3] borrow books---------------"<<endl;
cout<<"----[4] return books---------------"<<endl;
cout<<"----[5] output all books!----------"<<endl;
cout<<"----[6] output lended books!-------"<<endl;
cout<<"----[7] push return!---------------"<<endl;
cout<<"----[8] EXIT-----------------------"<<endl;
cout<<"what do you want?"<<endl;
cin>>ch;
switch(ch)
{case 1:addbook();break;
case 2:demand();break;
case 3:loan();break;
case 4:send();break;
case 5:output();break;
case 6:output_lend();break;
case 8:break;}
cout<<"Are you EXIT the system?"<<endl;
cin>>y;
if(y=='y') break;}}

热心网友 时间:2023-10-26 03:28

呵呵,楼主这个东西可不是几行代码就能搞定的哦~~去csdn下载个吧~~我分不够偶没法帮你下

热心网友 时间:2023-10-26 03:29

········自己不学 以后都没有用的~~

热心网友 时间:2023-10-26 03:29

上百度文库搜

热心网友 时间:2023-10-26 03:27

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>//输入/输出文件流类
using namespace std;
const int Maxr=100;//最多的读者
const int Maxb=100;//最多的图书
const int Maxbor=5;//每位读者最多借五本书
//读者类,实现对读者的信息的描述

class Reader
{
private:
int tag; //删除标记 1:已删 0:未删
int no; //读者编号
char name[10]; //读者姓名
int borbook[Maxbor];//所借图书
public:
Reader() {}
char *getname() {return name;} //获取姓名
int gettag() {return tag;} //获取删除标记
int getno() {return no;} //获取读者编号
void setname(char na[]) //设置姓名
{
strcpy(name,na);

}
void delbook(){ tag=1; }//设置删除标记 1:已删 0:未删
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;
return 1;

}
}
return 0;
}
void disp()//读出读者信息
{
cout << setw(5) << no <<setw(10) << name<<"借书编号:[";
for(int i=0;i<Maxbor;i++)
if(borbook[i]!=0)
cout << borbook[i] << "|";
cout << "]"<<endl;

}
};
//读者类库,实现建立读者的个人资料
class RDatabase
{
private:
int top; //读者记录指针
Reader read[Maxr];//读者记录
public:
RDatabase() //构造函数,将reader.txt读到read[]中
{
Reader s;
top=-1;
fstream file("reader.txt",ios::in);//打开一个输入文件
while (1)
{
file.read((char *)&s,sizeof(s));
if (!file)break;
top++;
read[top]=s;
}
file.close(); //关闭 reader.txt
}
void clear()//删除所有读者信息
{
top=-1;
}
int addreader(int n,char *na)//添加读者时先查找是否存在
{
Reader *p=query(n);
if (p==NULL)
{
top++;
read[top].addreader(n,na);
return 1;
}
return 0;
}
Reader *query(int readerid)//按编号查找
{
for (int i=0;i<=top;i++)
if (read[i].getno()==readerid &&
read[i].gettag()==0)
{
return &read[i];
}
return NULL;
}
void disp() //输出所有读者信息
{
for (int i=0;i<=top;i++)
read[i].disp();
}
void readerdata();//读者库维护
~RDatabase() //析构函数,将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 choice;
char rname[20];
int readerid;
Reader *r;
while (choice!='0')
{
cout <<"\n\n\t\t\t读 者 维 护\n\n\n\t\t 1 新 增\n\n\t\t 2 更 改\n\n\t\t 3 删 除\n\n\t\t 4 查 找\n\n\t\t 5 显 示\n\n\t\t 6 全 删\n\n\t\t 0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入读者编号:";
cin >> readerid;
cout << "输入读者姓名:";
cin >> rname;
addreader (readerid,rname);
break;
case '2':
cout << "输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout << " 该读者不存在 "<<endl;
break;
}
cout << "输入新的姓名:";
cin >> rname;
r->setname(rname);
break;
case '3':
cout << " 输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<" 该读者不存在" << endl;
break;
}
r->delbook();
break;
case '4':
cout << "读入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<"该读者不存在"<< endl;
break;
}
r->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:cout<<"输入错误,请从新输入:";break;
}
}
}

//图书类,实现对图书的描述,图书的编号,书名,借出,还入等
class Book
{
private:
int tag;//删除标记 1:已删 0:未删
int no;//图书编号
char name[20];//书名
int onshelf;//是否再架 1:再架 2:已借
public:
Book(){}
char *getname() { return name; }//获取姓名
int getno(){ return no; }//获取图书编号
int gettag(){ return tag; }//获取删除标记
void setname(char na[])//设置书名
{
strcpy(name,na);
}
void delbook(){ tag=1;}//删除图书
void addbook(int n,char *na)//增加图书
{
tag=0;
no=n;
strcpy(name,na);
onshelf=1;
}
int borrowbook()//借书操作
{
if (onshelf==1)
{
onshelf=0;
return 1;
}
return 0;
}
void retbook()//还书操作
{
onshelf=1;
}
void disp()//输出图书
{
cout << setw(6) << no << setw(18) << name << setw(10)
<<(onshelf==1? "在架":"已借") <<endl;
}
};

//图书库类,实现对图书的维护,查找,删除等
class BDatabase
{
private:
int top; //图*录指针
Book book[Maxb]; //图*录
public:
BDatabase()//构造函数,将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()//全删
{
top=-1;
}
int addbook(int n,char *na)//增加图书
{
Book *p=query(n);
if (NULL==p)
{
top++;
book[top].addbook(n,na);
return 1;
}
return 0;
}
Book *query(int bookid)//查找图书
{
for (int i=0;i<=top;i++)
if (book[i].getno()==bookid &&book[i].gettag()==0)
{
return &book[i];
}
return NULL;
}
void bookdata();//图书库维护
void disp()
{
for (int i=0;i<=top;i++)
if (book[i].gettag()==0)
book[i].disp();
}
~BDatabase()//析构函数,将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 choice;
char bname[40];
int bookid;
Book *b;
while (choice!='0')
{
cout <<"\n\n\n\t\t\t图 书 维 护 "<<endl<<endl;
cout<<"\t\t1 新 增\n \t\t2 更 改\n\t\t3 删 除\n\t\t4 查 找\n\t\t5 显 示\n\t\t6 全 删\n\t\t0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入图书编号:"<<endl;
cin >> bookid;
cout << "输入图书书名:"<<endl;
cin >> bname;
addbook(bookid,bname);
break;
case '2':
cout << "输入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout << " 该图书不存在 "<<endl;
break;
}
cout << "输入新的书名:"<<endl;
cin >> bname;
b->setname(bname);
break;
case '3':
cout <<" 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在" << endl;
break;
}
b->delbook();
break;
case '4':
cout << " 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在"<< endl;
break;
}
b->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:cout<<"输入错误,请从新输入:";
}
}
}
//main() 函数的实现,程序的主界面的引导
void main()
{
char choice;
int bookid,readerid;
RDatabase ReaderDB;
Reader *r;
BDatabase BookDB;
Book *b;
while(choice!='0')
{
cout <<endl<<endl<<"\t\t\t 图 书 管 理 系 统\n\n\n";

cout <<"\t\t\t1 借 书\n\n\t\t\t2 还 书 \n\n\t\t\t3 图 书 维 护\n\n\t\t\t4 读 者 维 护\n\n\t\t\t0 离 开"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout <<" 借书 读者编号:";
cin >>readerid;
cout <<" 图书编号: ";
cin >>bookid;
r=ReaderDB.query(readerid);//按编号查找
if (NULL==r)
{
cout <<" 不存在该读者,不能借书"<< endl;
break;
}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能借书"<< endl;
break;
}
if (b->borrowbook()==0)
{
cout << " 该图书已借出,不能借书"<< endl;
break;
}
r->borrowbook(b->getno());
break;
case '2':
cout<<"还书\n 读者编号:";
cin >>readerid;
cout << " 图书编号:";
cin >>bookid;
r=ReaderDB.query(readerid);
if (r==NULL)
{
cout <<" 不存在该读者,不能还书" << endl;
break;
}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能还书" <<endl;
break;
}
b->retbook();
r->retbook(b->getno());
break;
case '3':
BookDB.bookdata();
break;
case '4':
ReaderDB.readerdata();
break;
default:cout<<"输入错误,请从新输入:";
}
}
}

热心网友 时间:2023-10-26 03:28

#include<iostream.h>
#include<string.h>
#include<stdio.h>
const n=100;
int m=0;
class Book
{
private:
unsigned long no;
char name[35]; //书名
char author[20];//作者
char cbs[20]; //出版社
char key[5][20];//关键词
int onshelf; //是否再架 1:再架 2:已借
char lender[20];
unsigned long phone;
int y,m,d;
public:
void init();//初始化
friend void output();
friend void output_lend();
friend void way_1();
friend void way_2();
friend void way_3();
friend void loan();
friend void send();
};
Book p[n];
Book *k=p;
void Book::init()//初始化
{cout<<"Input the book NO!"<<endl;
cin>>no;
cout<<"Input the book name!"<<endl;
gets(name);
cout<<"Input the author!"<<endl;
gets(author);
cout<<"Input the publishing house!"<<endl;
gets(cbs);
for(int i=0;i<5;i++)
{cout<<"The "<<i+1<<" keyword:"<<endl;
gets(key[i]);
cout<<endl;
}
cout<<"Iuput the status!(0 or 1)"<<endl;
cin>>onshelf;
}
void demand()//查询图书
{int choose;
cout<<"Choose which kind of inquires the way?"<<endl;
cout<<"[1]Readers can provide the book name by queries!"<<endl;
cout<<"[2]Readers can by asking book NO query!"<<endl;
cout<<"[3]Readers can provide the keyword by queries!"<<endl;
cout<<"[4] EXIT!"<<endl;
cin>>choose;
if(choose==1) way_1();
else if(choose==2) way_2();
else if(choose==3) way_3();
else return;
}
void addbook()
{char y;
for(;;)
{m++;
k->init();
k++;
cout<<"------------Are you continue?---------"<<endl;
cin>>y;
if(y=='n') break;
}
}
void output()//输出信息
{
cout<<"-----------Output the DATE!---------"<<endl;
for(int i=0;i<m;i++)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl<<endl;}
}
void output_lend()
{cout<<"----------Output the book had been lend!---------"<<endl;
for(int i=0;i<m;i++)
{if(p[i].onshelf==1)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;
cout<<"KEYWORD:"<<p[i].key[0]<<" "<<p[i].key[1]<<" "<<p[i].key[2]<<" "<<p[i].key[3]<<" "<<p[i].key[4]<<endl;
cout<<"LENDER:"<<p[i].lender<<endl;
cout<<"PHONE:"<<p[i].phone<<endl;
cout<<"LEND DATE:"<<p[i].y<<" " <<p[i].m<<" " <<p[i].d<<endl<<endl;}
}}
void way_1()
{ char nam[35];
cout<<"-----------Input the book name !---------"<<endl;
gets(nam);
for(int i=0;i<m;i++)
{if(strcmp(p[i].name,nam)==0)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;return;
}
}
cout<<"NOT FIND!"<<endl;return;
}
void way_2()
{unsigned long na;
cout<<"Input the book NO !"<<endl;
cin>>na;
for(int i=0;i<m;i++)
{if(p[i].no==na)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;return;
}
}
cout<<"Input error!"<<endl;
}
void way_3()
{char keyword[30];
cout<<"------------Input the keyword !-------------"<<endl;
cin>>keyword;
for(int i=0;i<m;i++)
for(int j=0;j<5;j++)
if(strcmp(p[i].key[j],keyword)==0)
if(p[i].onshelf==0)
{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;}
}

void loan()//借书功能
{char y;
unsigned long n;
cout<<"Input the book NO!"<<endl;
cin>>n;
for(int i=0;i<m;i++)
if(n==p[i].no)
{if(p[i].onshelf==0)
{{cout<<"BOOK NO:"<<p[i].no<<endl;
cout<<"BOOK NAME:"<<p[i].name<<endl;
cout<<"AUTHOR:"<<p[i].author<<endl;
cout<<"publishing house:"<<p[i].cbs<<endl;
cout<<"Are you want to lend the book?"<<endl;
cin>>y;}
if(y=='y')
{cout<<"Registration borrowing the people's names!"<<endl;
cin>>p[i].lender;
cout<<"Registration lending people's telephone number!"<<endl;
cin>>p[i].phone;
cout<<"Registration lending date!"<<endl;
cin>>p[i].y>>p[i].m>>p[i].d;
p[i].onshelf=1;
cout<<"Borrow success!"<<endl;
return;
}}
}
cout<<"Input error!"<<endl;
return;
}
void send()//还书功能
{unsigned long n;
cout<<"Input the book NO!"<<endl;
cin>>n;
for(int i=0;i<m;i++)
{if(n==p[i].no)
{if(p[i].onshelf==1)
{p[i].onshelf=0;
cout<<"retuen success!"<<endl;return;}
}
}
cout<<"Input error!"<<endl;return;}

void main()
{ char y;
for(;;)
{int ch;
cout<<"---------------Library management system-----------------"<<endl;
cout<<"-----------------------MENU------------------------"<<endl;
cout<<"----[1] Add books------------------"<<endl;
cout<<"----[2] check books----------------"<<endl;
cout<<"----[3] borrow books---------------"<<endl;
cout<<"----[4] return books---------------"<<endl;
cout<<"----[5] output all books!----------"<<endl;
cout<<"----[6] output lended books!-------"<<endl;
cout<<"----[7] push return!---------------"<<endl;
cout<<"----[8] EXIT-----------------------"<<endl;
cout<<"what do you want?"<<endl;
cin>>ch;
switch(ch)
{case 1:addbook();break;
case 2:demand();break;
case 3:loan();break;
case 4:send();break;
case 5:output();break;
case 6:output_lend();break;
case 8:break;}
cout<<"Are you EXIT the system?"<<endl;
cin>>y;
if(y=='y') break;}}

热心网友 时间:2023-10-26 03:28

呵呵,楼主这个东西可不是几行代码就能搞定的哦~~去csdn下载个吧~~我分不够偶没法帮你下

热心网友 时间:2023-10-26 03:29

········自己不学 以后都没有用的~~

热心网友 时间:2023-10-26 03:29

上百度文库搜
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
姐妹们,哥伦比亚的徒步鞋怎么样?下个月就要去吴越古道户外徒步旅行... 徒步装备选哪个牌子好 徒步小白上线!想问问大神们徒步鞋哥伦比亚户外活动性能如何?方便吗? 去医院怎么检查自己缺钙和缺维生素? 查缺钙做什么检查 骨骼缺钙怎么检查 检查缺钙查什么 joryaweekend是什么牌子 剪映在那里修改视频尺寸 剪映如何修改视频画面尺寸 修改视频画面尺寸方法分享 做图书馆管理系统的毕业设计都该实现哪些功能呢? 新公司注册资金900万元,没有出资,只有老公司的固定资产,新公司需要先出资900万元然后才能谈收购的问题吗 图书馆管理系统详细设计说明书 每天吃一个苹果,对我们的身体有什么好处? 求名言及诗句[责任,乐观,奋斗,勤奋,友谊,信任,智慧,感恩,积累,创新] 高考语文积累 求关于外国哲学家的名人名言及解释。为高考积累的,也可以推荐一些高考作文中常出现的哲学家的诗集。谢谢 相反数等于本身的数是,平方等于本身的数是,倒数等于本身的数是,绝对值等于本身的数是。 有关高考作文的名人名言的积累问题 如何编辑Word中标题和正文 苹果手机接不显示内容怎么设置 迪奥男士香水好不好用? 迪奥真我香水男士可以用吗? 注册资本9000万的公司算大吗 男士身上喷香水有什么作用? 费洛蒙香水对男人有用吗 香水除了增加女人的香味还有何用?男士可以用香水吗? 相反数与它本身相等的数是 ,倒数与它本身相等的数是 。 相反数等于它本身的数是 倒数等于它本身的数是 绝对值等于它本身的数是 在漯河出行买了汽车票,如何退票? 相反数等于本身的数有 ( ) ,倒数等于本身的数有( ) ,绝对值等于本身的数有 ( ) 。 相反数等于它本身的数有几个是什么倒数等于它本身绝对值等于 每天吃一个苹果,坚持下去的话,对身体有什么好处吗? 每天晚上吃一个苹果有什么好处啊? 深圳市吉日升机电制品有限公司怎么样? abc成立一家公司,注册资本900万,没人3分之一股份。2年后,吸收投资者d,注册资本变成1200 A,b,c三公司投资组成ABC公司。注册资本900万三方各占3分之一股份。A公司以厂房投资,此厂房 晚上吃苹果对身体有好处吗? 请问瞄财网是正规的吗? 每天晚上睡觉前一个半小时吃个苹果会有什么好处吗? 毕业设计(图书馆管理系统)具体的6人分工 我们公司注册资金一千万,其中900万是借的,验资后马上还了人家904万,4万是属于利息。这笔账怎么做呢 2、 图书信息管理系统设计 儿童睡前故事里三只小猪讲的主要是什么内容呢? 每天吃一个苹果对我们的健康有怎样的好处? 每天吃一个苹果有什么好处 让人惊喜 雅思听力到底该怎么提高? 倒数等于它自己的数是___,相反数等于它自己的数是___. 请问各位高三毕业的,你们是如何摘抄名人名言和名人事例的,或者是去哪里摘抄 快高考了,老班要我想一句写在后面黑板上的励志的话。要求:要从学习是点滴积累的,一口吃不成个胖子这...