#include
#include
#include
#include
using namespace std;
void mainmenu();
void Manage_Book();
void input_Book();
void input_Reader();
void New_Book();
void Seek_Book();
void Borrow_Manage();
void Borrow_Book();
void Return_Book();
void Output_Message();
void Exit_System();
int u,v=3,k=0;
struct Book
{
char name[20];
int booknumber;
int num_present;
int num_all;
}book[1000];
struct Reader
{
char name[20];
int readernumber;
int card;
}reader[3];
void mainmenu()
{
int Num_Choice1,flag=1;
system("color E");
for(;k<=0;k++)
{
input_Book();
input_Reader();
}
while(flag==1)
{
system("cls");
cout<<"\t\t\t◆◆◆◆◆主菜单◆◆◆◆◆"<
switch(Num_Choice1)
{
case 1:
Manage_Book();
break;
case 2:
Borrow_Manage();
break;
case 3:
Output_Message();
break;
case 4:
Exit_System();
flag=0;
break;
default:
flag=0;
cout<<"输入有误!!"<
}
}
void Manage_Book()
{
int flag1=1,Num_Choice2;
system("cls"); while(flag1==1)
{
cout<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<
switch(Num_Choice2)
{
case 1:
flag1=2;
New_Book();
break;
case 2:
flag1=2;
Seek_Book();
break;
case 3:
mainmenu();
default:
flag1=1;
cout<<"输入有误!"<
system("cls");
}
}}
void input_Book()
{
cout<<"请依照提示输入现有的三本图书的信息:"<
{
cout<<"书名:"<
cout<<"书号:"<
cout<<"库存量:"<
cout<<"现存量:"<
}
}
void New_Book()
{
system("cls");
int j;
char newbook_name[20];
cout<<"请输入新书书名:"<
for(j=0;j<1000;j++)
{
if(strcmp(newbook_name,book[j].name)==0)
{
book[j].num_all++;
book[j].num_present++;
break;
}
}
if(j==1000)
{
cout<<"请为此新书编号:"<
cin>>book[v].booknumber;
strcpy(book[v].name,newbook_name);
book[v].num_all=1;
book[v].num_present=1;
}
else cout<<"已有此书,库存量加一"<
}
void Seek_Book()
{
system("cls");
int k,booknumber;
cout<<"请输入所要查询的书号:"<
for(k=0;k<1000;k++)
{
if(book[k].booknumber==booknumber)
{
cout<<"书号:"<
break;
}
}
if(k==1000)
{
cout<<"未找到此书!!"<
}
}
void Borrow_Manage()
{
int flag=1;
system("cls");
int Num_Choice3;
while(flag==1)
{
cout<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<
switch(Num_Choice3)
{
case 1:
flag=2;
Borrow_Book();
break;
case 2:
flag=2;
Return_Book();
break;
case 3:
mainmenu();
default:
flag=1;
cout<<"输入有误!!"<
}
system("cls");
}
}
void input_Reader()
{
system("cls");
cout<<"请依照提示输入现有的三位读者的信息:"<
{
cout<<"姓名:"<
cout<<"编号:"<
reader[m].card=0;
}
}
void Borrow_Book()
{
system("cls");
char reader_name[20];
int n,book_number;
cout<<"请输入读者姓名:"<
for(n=0;n<3;n++)
{
if(strcmp(reader_name,reader[n].name)==0)
{
if(reader[n].card!=0)
{
cout<<"已借书,不能再借,请按任意键返回"<
mainmenu();
}
else
break;
}
}
if(n==3)
{
cout<<"无此读者!输入有误!!按任意键返回主菜单"<
mainmenu();
}
cout<<"请输入所借图书书号:"<
for(n=0;n
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=book_number;
}
for(n=0;n
if(book[n].booknumber==book_number)
{
if(book[n].num_present==0)
{
cout<<"该书已经被借完,请按任意键返回"<
for(n=0;n
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=0;
}
mainmenu();
}
else
{
book[n].num_present--;
cout<<"借书成功,请按任意键返回"<
break;
}
}
}
if(n==v)
{
for(n=0;n
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=0;
}
cout<<"所输入的书号不存在,请按任意键返回主菜单"<
mainmenu();
}
}void Return_Book()
{
system("cls");
int j;
char reader_name[20];
int book_number;
cout<<"请输入读者姓名:"<
for(j=0;j<3;j++)
{
if(strcmp(reader_name,reader[j].name)==0)
break;
}
if(j==3)
{
cout<<"无此读者!输入有误!!按任意键返回主菜单"<
mainmenu();
}
cout<<"请输入所还图书书号:"<
for(j=0;j<3;j++)
{
if(strcmp(reader_name,reader[j].name)==0)
{
if(book_number==reader[j].card)
{
reader[j].card=0;
for(j=0;j
if(book[j].booknumber==book_number)
{
book[j].num_present++;
cout<<"还书成功,请按任意键返回"<
break;
}
}
}
else
{
cout<<"该读者未借此书"<
}
}
if(j==v)
cout<<"所输入的书号不存在:"<
}
void Output_Message()
{
system("cls");
int q;
cout<<"以下是图书信息"<
cout<<"书号:"<
cout<<"以下是读者信息"<
{
cout<<"姓名:"<
system("pause");
}
void Exit_System()
{
system("cls");
cout<<"欢迎下次使用,谢谢"<
}
void main()
{
mainmenu();
}
我写了好几个这样的系统,只是源码还在电脑上,回去我发给你