c++图书管理系统课程设计源代码,c语言编写图书管理系统

c++图书管理系统课程设计源代码,c语言编写图书管理系统,C++图书管理系统程序源代码

本文主要详细介绍了C图书管理系统程序的源代码。本文中的示例代码非常详细,具有一定的参考价值。感兴趣的朋友可以参考一下。

本文将C图书管理系统程序的具体代码分享出来,供大家参考。具体内容如下

第一学期期末c综合实验,功能基本实现,但代码编写有些繁琐,还有很大的优化空间,仅供参考。

实验要求

实验目的:

1.综合运用面向对象的编程方法,可以设计并实现一个相对完整的信息管理应用。

2.能够恰当地进行课题分析、实验设计、核心代码描述、实验结果分析等。

实验:设计编写一个C风格的应用程序,模拟一个图书管理系统应用程序,支持系统用户的图书借阅、图书管理、用户管理等功能。图书借阅管理主要包括图书借阅、图书归还、借阅信息查看等功能。图书管理主要包括图书的增加、删除、修改、查看和统计等功能。用户管理主要包括用户注册、登录、密码修改、个人信息修改、用户类型设置等功能。

具体要求:

1.在图书管理系统中定义图书书目类(也可以定义用户类、日志图书借出和归还日志类等。).

2.合理应用类的继承来定义图书馆资源的继承,图书馆资源可以分为图书、光盘、电子资源等。(或者系统用户可以分为读者、馆员、系统管理员)。

3.根据不同类型的用户,登录系统显示不同的用户功能菜单,实现不同的操作,比如学生和老师借阅图书的数量和天数不同(或者各种图书馆资源支持的用户操作不同)。

4.增加异常处理。借书时会给出最多可以借多少本的提示;当书被归还时,它们已经过期了,需要支付罚款。

5.利用重载运算符“”和“”方便图书信息和读者信息的输入,将图书信息和借阅记录保存到磁盘,从而形成图书借阅和归还日志文件。

6.扩展实验:可以尝试使用MFC可视化界面,提高用户的便利性和友好性。

程序源代码

#includeiostream

# includecstring

# includectime

# include stream//文件输入和输出

#includeiomanip//控制输入和输出格式

#pragma warning(disable:4996)//消除strcpy不安全的错误信息。

#定义kouling2 '654321 '

使用命名空间std

TT {//系统当前时间

公共:

int年;

int月;

int日;

int小时;

int分钟;

int秒;

tt() {}

};

Tt时间()//获取当前时间

{

TT PP;

现在时间;

struct TM * p;

时间(now time);

p=local time(now time);

PP . year=p-TM _ year 1900;

PP . month=p-TM _ mon 1;

PP . day=p-TM _ mday;

PP . hours=p-TM _ hour;

PP . minutes=p-TM _ min;

PP . seconds=p-TM _ sec;

返回PP;

}

班级日志;

类图书{//书目类

受保护:

夏尔邢蕾[50];//书籍类型,包括纸质书、光盘、电子书。

int号;//没有。

char name[50];//书名

char作者[50];//作者

char press[50];//出版社

char price[50];//价格

int状态;//书是否在架,1在架,0借。

公共:

Book(){}

好友日志;

Void set_name(char a[])//设置书名

{

strcpy(名称,a);

}

Void set_author(char a[])//设置作者

{

strcpy(作者,a);

}

Void set_press(char a[])//设置出版社

{

strcpy(按,a);

}

Void set_price(char a[])//设置价格

{

strcpy(价格,a);

}

Void set_no(int a)//设置数量

{

否=a;

}

Void set_state(int a)//设置图书状态

{

state=a;

}

Char *get_name()//获取书名

{

返回名称;

}

Char *get_author()//获取作者

{

返回作者;

}

Char* get_press()//获取出版社

{

回压;

}

Char* get_price()//获取价格

{

退货价格;

}

Get _ no()//获取号码

{

返回否;

}

Get _ state()//获取图书状态

{

返回状态;

}

Int chongfu_no(int no1)//判断数字是否重复,返回1为重复,0为非重复。

{

夏尔邢蕾[100][50];//书籍类型

int x[100];//图书编号

char c[100][50];//书名

char d[100][50];//图书作者

char e[100][50];//图书出版社

char f[100][20];//价格

int YY[100];//状态

int I;

fstream in

in.open('Book.text ',IOs:in);

for(I=0;我)

{

If (in.eof())//判断是否在文件末尾。

{

打破;

}

在邢蕾,x,c,d,e,f,y;//读入图书信息

If (no1==x[i])//该号码已经存在

{

Cout '未能添加图书,该号码已经存在!'endl

返回1;

}

}

in . close();

返回0;

}

};

类{//用户类

受保护:

char name[20];//用户名

char密码[20];//密码

公共:

用户(){}

好友日志;

Void set_name(char a[])//设置用户名

{

strcpy(名称,a);

}

Void set_password(char a[])//设置密码

{

strcpy(密码,a);

}

Int chongfu_name(char a[])//检查用户名是否已经存在,返回1为存在。

{

int I;

int num=0;//注册用户的数量

char d[100][50];//注册用户类型

char e[100][50];//注册的用户名

char f[100][50];//注册密码

fstream in

in.open('User.text ',IOs:in);

for(I=0;我)

{

If (in.eof())//判断是否在文件末尾。

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

num

}

in . close();

for(I=0;inum我)

{

If (strcmp(a,e[i])==0)//用户名已经存在

返回1;

}

返回0;

}

Voidchange _ information (char a [],int n)//修改用户名,其中n为1修改用户名,2修改密码。

{

int I;

int num=0;//注册用户的数量

char d[100][20];//注册用户类型

char e[100][20];//注册的用户名

char f[100][20];//注册密码

fstream in

in.open('User.text ',IOs:in);

for(I=0;I )//获取注册用户信息

{

If (in.eof())//判断是否在文件末尾。

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

If (strcmp(e[i],name)==0)//找到要修改的用户

{

如果(n==1)

{

memset(name,' \0 ',sizeof(name));//清空数组

strcpy(名称,a);

memset(e[i],' \0 ',sizeof(e[I]);//清空数组

strcpy(e[i],a);

}

如果(n==2)

{

memset(密码,' \0 ',sizeof(密码));//清空数组

strcpy(密码,a);

memset(f[i],' \0 ',sizeof(f[I]);//清空数组

strcpy(f[i],a);

}

}

num

}

in . close();

fstream out

out.open('User.text ',IOs:out | IOs:trunc);

for(I=0;inumI )//将修改后的用户信息写入文件。

{

If(strcmp(d[i],' readers ')//读者

out setios flags(IOs:left)setw(20)d[I]setw(20)e[I]setw(20)f[I]endl;

Else//图书管理员或系统管理员

out setios flags(IOs:left)setw(14)d[I]setw(20)e[I]setw(20)f[I]endl;

}

out . close();

Cout '修改成功!'endl

}

int Glu(const char p[])//用户登录时,返回1为登录成功,返回0为登录失败。

{

int I;

int num=0;//注册用户的数量

char d[100][20];//注册用户类型

char e[100][20];//注册的用户名

char f[100][20];//注册密码

fstream in

in.open('User.text ',IOs:in);

for(I=0;I )//获取注册用户信息

{

If (in.eof())//确定文件是否在末尾。

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

num

}

in . close();

int flag=0;//0为登录失败,1为登录成功。

char a[20];//登录用户名

char b[20];//登录密码

' Cout '请输入用户名:' endl

CIN a;

' Cout '请输入密码:' endl

CIN b;

for(I=0;i num我)

{

If (strcmp (p,d [I])==0 strcmp (a,e [I])==0 strcmp (b,f[I])==0)/登录成功

{

flag=1;

打破;

}

}

If (flag==1)//登录成功

{

Cout:您好!亲爱的p e[I]endl;

strcpy(名称,a);

strcpy(密码,b);

返回1;

}

If(flag==0)//登录失败

{

Cout '登录失败,用户名或密码错误' endl

返回0;

}

}

};

类读取器:公共用户{//读取器类

公共:

读者():用户()

{

}

Void zhuce()//注册读者

{

int I;

int num=0;//注册用户的数量

char d[100][50];//注册用户类型

char e[100][50];//注册的用户名

char f[100][50];//注册密码

fstream in

in.open('User.text ',IOs:in);

for(I=0;我)

{

If (in.eof())//判断是否在文件末尾。

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

num

}

in . close();

char a[20];//要注册的用户名

' Cout '请输入用户名:' endl

int flag=1;//0是注册的用户名,1是未注册的。

for(;)//输入用户名

{

char aa[20];//临时存储要注册的用户名

CIN aa;

for(I=0;i numI )//确定用户名是否已经注册。

{

If (strcmp(e[i],aa)==0)//用户名已经注册

{

' Cout '用户名已经存在,请重新输入:' endl

flag=0;

打破;

}

其他

{

flag=1;

}

}

If (flag==1)//用户名未注册

{

strcpy(a,aa);

打破;

}

}

for(;)

{

char b[20];//密码

char c[20];//第二次输入的密码

' Cout '请设置密码:' endl

CIN b;

' Cout '请再次输入密码:' endl

CIN c;

If (strcmp(b,c)==0)//两次密码输入一致。

{

Cout '注册成功!'endl

set _ name(a);

set _ password(b);

fstream out

out.open('User.text ',IOs:app);

out setios flags(IOs:left)setw(18)' reader ' setw(20)a setw(20)b endl;//将用户信息写入文件

out . close();

打破;

}

其他

{

Cout '两个密码不一致,请重新输入' endl'

}

}

}

};

类Librarian:公共用户{//librarian类

公共:

Void zhuce()//注册图书管理员

{

int I;

int num=0;//注册用户的数量

char d[100][10];//注册用户类型

char e[100][20];//注册的用户名

char f[100][20];//注册密码

fstream in

in.open('User.text ',IOs:in);

for(I=0;我)

{

If (in.eof())//确定文件是否在末尾。

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

num

}

in . close();

char a[20];//要注册的用户名

' Cout '请输入用户名:' endl

int flag=1;//0是注册的用户名,1是未注册的。

for(;)//输入用户名

{

char aa[20];//临时存储要注册的用户名

CIN aa;

for(I=0;i numI )//确定用户名是否已经注册。

{

if (strcmp(e[i],aa)==0)

{

' Cout '用户名已经存在,请重新输入:' endl

flag=0;

打破;

}

其他

{

flag=1;

}

}

if (flag==1)

{

strcpy(a,aa);

打破;

}

}

for(;)

{

char b[20];//密码

char c[20];//第二次输入的密码

' Cout '请设置密码:' endl

CIN b;

' Cout '请再次输入密码:' endl

CIN c;

if (strcmp(b,c)==0)

{

Cout '注册成功!'endl

set _ name(a);

set _ password(b);

fstream out

out.open('User.text ',IOs:app);

outios flags(iOS:left)SETW(14)' Librarian ' SETW(20)a SETW(20)b endl;

出去。close();

打破;

}

其他

{

cout '两次密码不一致,请重新输入恩德尔

}

}

}

void add_book(int no1,char name1[],char author1[],char press1[],char price1[],int y)//增加图书

{

流输出

out.open('Book.text ',IOs:app);

if (y==1)//纸质图书

"出去"纸质图书;

if (y==2)//碟片

"出去"碟片;

if (y==3)//电子书

"出去"电子书;

out setios flags(IOs:left)setw(15)no1 setw(20)name 1 setw(20)author 1 setw(20)press 1 setw(20)price 1 setw(5)1 endl;//最后一个左对齐能否去掉

出去。close();

cout '增加图书成功!'恩德尔

}

void delete_book(int n)//删除图书信息

{

int I;

int num=0;

夏尔邢蕾[100][50];//图书类型

int x[100];//图书编号

char c[100][50];//图书书名

char d[100][50];//图书作者

char e[100][50];//图书出版社

char f[100][20];//价格

int y[100];//状态

int flag=0;//1为存在该书,0为不存在

fstream输入

in.open('Book.text ',IOs:in);

for(I=0;我)

{

if (in.eof())//判断文件是否到末尾

{

num-;//

打破;

}

在邢蕾x I c I d I e I f I y I

num//

}

英寸close();

流输出

out.open('Book.text ',IOs:out);

for(I=0;i numi )//将删除图书后的的图书信息写入文件

{

if (x[i]!=n)

输出setios标志(IOs:left)setw(20)邢蕾[I]setw(15)x[I]setw(20)c[I]setw(20)d[I]setw(20)e[I]setw(20)f[I]setw(5)y[I]endl;//最后一个左对齐能否去掉

其他

flag=1;

}

出去。close();

if(flag==1)

cout '删除成功!'恩德尔

如果(标志==0)

cout '删除失败,未查找到该书!'恩德尔

}

作废变更_book(int n)//修改图书信息

{

int I;

int num=0;

夏尔邢蕾[100][50];//图书类型

int x[100];//图书编号

char c[100][50];//图书书名

char d[100][50];//图书作者

char e[100][50];//图书出版社

char f[100][20];//价格

int y[100];//状态

fstream输入

in.open('Book.text ',IOs:in);

for(I=0;我)

{

if (in.eof())

{

num-;//

打破;

}

在邢蕾x I c I d I e I f I y I

num//

}

英寸close();

for(I=0;我编号我)

{

if (n==x[i])//找到要修改的图书

{

记忆集(邢蕾[i],' \0 ',sizeof(邢蕾【我】);

x[I]=0;

memset(c[i],' \0 ',sizeof(c[I]);

memset(d[i],' \0 ',sizeof(d[I]);

memset(e[i],' \0 ',sizeof(e[I]);

memset(f[i],' \0 ',sizeof(f[I]);

y[I]=0;

cout '请输入修改后的图书类型:' endl

CIN邢蕾[I];

cout '请输入修改后的图书编号:' endl

cin十大;

cout '请输入修改后的图书书名:' endl

CIN c[I];

cout '请输入修改后的图书作者:' endl

CIN迪[伊];

cout '请输入修改后的图书出版社:' endl

CIN e[I];

cout '请输入修改后的图书价格:' endl

CIN f[I];

cout '请输入修改后的图书状态:(1为在架,0为已借出)endl

CIN y[I];

cout '修改成功!'恩德尔

打破;

}

}

if (i==num)//未查找到图书

cout '抱歉,未查到此书!'恩德尔

流输出

out.open('Book.text ',IOs:out);

for(I=0;i numi )//将修改后的图书信息写入文件

{

输出setios标志(IOs:left)setw(20)邢蕾[I]setw(15)x[I]setw(20)c[I]setw(20)d[I];

out setw(20)e[I]setw(20)f[I]setw(5)y[I]endl;

}

出去。close();

}

void see_all()//查看所有用户的借阅信息

{

int I;

int num=0;

char a[100][20];//图书类型

char b[100][20];//编号

char c[100][20];//书名

char d[100][20];//作者

char e[100][20];//出版社

char f[100][20];//价格

茶人[100][20];//借书人

TT p;//借书时间

fstream out2

out2.open('Log.text ',IOs:in);

for(I=0;我)

{

if (out2.eof())//判断是否到文件末尾

{

num-;

打破;

}

out 2 a[I]b[I]c[I]d[I]e[I]f[I];

out2人[I];

out2 p年p月p日p小时p分p秒;

数字

}

out 2。close();

cout '以下为所有用户借阅信息:' endl

for(I=0;我编号我)

{

' cout a[I]' ' b[I]' ' c[I]d[I]' ' e[I]' ' f[I]' ' '借阅人:'人民[我]' p。年'年p。月'月下午一点日p . hours ':' p . minutes endl;

}

}

};

类系统管理员:公共用户{//系统管理员类

公共:

void zhuce()//注册系统管理员

{

int I;

int num=0;//已注册的用户量

char d[100][10];//已注册的用户类型

char e[100][20];//已注册的用户名

char f[100][20];//已注册的密码

fstream输入

in.open('User.text ',IOs:in);

for(I=0;我)

{

if (in.eof())

{

num-;

打破;

}

在d[i]中;

在e[i]中;

在f[i]中;

数字

}

英寸close();

char a[20];//所要注册的用户名

cout '请输入用户名:' endl

int flag=1;//0为用户名已注册,1为未注册

for(;)//输入用户名

{

char aa[20];//暂时存储所要注册的用户名

CIN aa;

for(I=0;i numi )//判断用户名是否已注册

{

if (strcmp(e[i],aa)==0)

{

cout '该用户名已存在,请重新输入:' endl

flag=0;

打破;

}

其他

{

flag=1;

}

}

if (flag==1)

{

strcpy(a,aa);

打破;

}

}

for(;)

{

char b[20];//密码

char c[20];//第二次输入的密码

cout '请设置密码:' endl

CIN b;

cout '请再次输入密码:' endl

CIN c;

if (strcmp(b,c)==0)

{

cout '注册成功!'恩德尔

set _ name(a);

set _ password(b);

流输出

out.open('User.text ',IOs:app);

' out setios flags(IOs:left)setw(14)'系统管理员setw(20)a setw(20)b endl;

出去。close();

打破;

}

其他

{

cout '两次密码不一致,请重新输入恩德尔

}

}

}

void add_User(字符名称[],字符密码[],int y)//增加用户

{

如果(崇福_name(name)==1)//用户名已注册

cout '增加用户失败,该用户名已存在!

" << endl; ? ? ? ? if (chongfu_name(name) == 0)//用户名未注册 ? ? ? ? { ? ? ? ? ? ? fstream out; ? ? ? ? ? ? out.open("User.text", ios::app); ? ? ? ? ? ? if (y == 1) ? ? ? ? ? ? ? ? out << setiosflags(ios::left) << setw(18) << "读者" << setw(20) << name << setw(20) << password << endl; ? ? ? ? ? ? if (y == 2) ? ? ? ? ? ? ? ? out << setiosflags(ios::left) << setw(14) << "图书管理员" << setw(20) << name << setw(20) << password << endl; ? ? ? ? ? ? out.close(); ? ? ? ? ? ? cout << "增加成功!" << endl; ? ? ? ? } ? ? } ? ? void delete_user(char name[])//删除用户 ? ? { ? ? ? ? int i; ? ? ? ? int num = 0;//已注册的用户量 ? ? ? ? char d[100][50];//已注册的用户类型 ? ? ? ? char e[100][50];//已注册的用户名 ? ? ? ? char f[100][50];//已注册的密码 ? ? ? ? int del;//要删除的用户的序号 ? ? ? ? fstream in; ? ? ? ? in.open("User.text", ios::in); ? ? ? ? for (i = 0;; i++) ? ? ? ? { ? ? ? ? ? ? if (in.eof())//判断是否到文件末尾 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? num--; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? in >> d[i]; ? ? ? ? ? ? in >> e[i]; ? ? ? ? ? ? in >> f[i]; ? ? ? ? ? ? num++; ? ? ? ? } ? ? ? ? in.close(); ? ? ? ? for (i = 0;i<num; i++) ? ? ? ? { ? ? ? ? ? ? if (strcmp(name, e[i]) == 0)//找到该用户 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? del = i;//记录i ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (i == num)//未查找到该用户名 ? ? ? ? { ? ? ? ? ? ? cout << "未查找到该用户!" << endl; ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? fstream out; ? ? ? ? out.open("User.text", ios::out); ? ? ? ? for (i = 0;i<num; i++)//将删除后的全部用户信息写入文件 ? ? ? ? { ? ? ? ? ? ? if(i!=del) ? ? ? ? ? ? out << setiosflags(ios::left) << setw(20) << d[i]<< setw(20) << e[i] << setw(20) << f[i] << endl; ? ? ? ? } ? ? ? ? out.close(); ? ? ? ? cout << "删除成功!" << endl; ? ? } ? ? void change_user(char name[],int y)//修改用户信息,y=1为用户类型,y=2为用户名,y=3为用户密码 ? ? { ? ? ? ? int i; ? ? ? ? int num = 0;//已注册的用户量 ? ? ? ? char d[100][50];//已注册的用户类型 ? ? ? ? char e[100][50];//已注册的用户名 ? ? ? ? char f[100][50];//已注册的密码 ? ? ? ? fstream in; ? ? ? ? in.open("User.text", ios::in); ? ? ? ? for (i = 0;; i++) ? ? ? ? { ? ? ? ? ? ? if (in.eof())//判断文件是否到末尾 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? num--; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? in >> d[i]; ? ? ? ? ? ? in >> e[i]; ? ? ? ? ? ? in >> f[i]; ? ? ? ? ? ? num++; ? ? ? ? } ? ? ? ? in.close(); ? ? ? ? if (y == 1)//修改用户类型 ? ? ? ? { ? ? ? ? ? ? for (i = 0;i<num; i++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (strcmp(name, e[i]) == 0)//找到该用户 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? if (strcmp(d[i], "读者") == 0)//该用户为读者 ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? memset(d[i], '\0', sizeof(d[i]));//清空用户类型数组 ? ? ? ? ? ? ? ? ? ? ? ? strcpy(d[i], "图书管理员"); ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? else//该用户为图书管理员 ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? memset(d[i], '\0', sizeof(d[i]));//清空用户类型数组 ? ? ? ? ? ? ? ? ? ? ? ? strcpy(d[i], "读者"); ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? if (i == num) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? cout << "未查找到该用户!" << endl; ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (y == 2)//修改用户名 ? ? ? ? { ? ? ? ? ? ? char name2[50];//修改后的用户名 ? ? ? ? ? ? for (;;) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? char name1[50];//暂时存储修改后的用户名 ? ? ? ? ? ? ? ? cout << "请输入修改后的用户名:" << endl; ? ? ? ? ? ? ? ? cin >> name1; ? ? ? ? ? ? ? ? if (chongfu_name(name1) == 1)//用户名已存在 ? ? ? ? ? ? ? ? ? ? cout << "该用户名已存在,请重新输入" << endl; ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? strcpy(name2, name1); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? for (i = 0;; i++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (strcmp(name, e[i]) == 0)//找到要修改的用户 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? memset(e[i], '\0', sizeof(e[i]));//清空用户名 ? ? ? ? ? ? ? ? ? ? strcpy(e[i], name2); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (y == 3)//修改密码 ? ? ? ? { ? ? ? ? ? ? char password2[50]; ? ? ? ? ? ? cout << "请输入修改后的密码:" << endl; ? ? ? ? ? ? cin >> password2; ? ? ? ? ? ? for (i = 0;; i++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (strcmp(name, e[i]) == 0) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? memset(f[i], '\0', sizeof(f[i])); ? ? ? ? ? ? ? ? ? ? strcpy(f[i], password2); ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? fstream out; ? ? ? ? out.open("User.text", ios::out); ? ? ? ? for (i = 0;i<num; i++) ? ? ? ? { ? ? ? ? ? ? out << setiosflags(ios::left) << setw(20) << d[i] << setw(20) << e[i] << setw(20) << f[i] << endl; ? ? ? ? } ? ? ? ? out.close(); ? ? ? ? cout << "修改成功!" << endl; ? ? } ? ? void see_user()//查看所有用户信息 ? ? { ? ? ? ? int i; ? ? ? ? int num = 0;//已注册的用户量 ? ? ? ? char d[100][50];//已注册的用户类型 ? ? ? ? char e[100][50];//已注册的用户名 ? ? ? ? char f[100][50];//已注册的密码 ? ? ? ? fstream in; ? ? ? ? in.open("User.text", ios::in); ? ? ? ? for (i = 0;; i++) ? ? ? ? { ? ? ? ? ? ? if (in.eof()) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? num--; ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? in >> d[i]; ? ? ? ? ? ? in >> e[i]; ? ? ? ? ? ? in >> f[i]; ? ? ? ? ? ? num++; ? ? ? ? } ? ? ? ? in.close(); ? ? ? ? cout << "——————————用户信息——————————" << endl; ? ? ? ? for (i = 0; i < num; i++) ? ? ? ? { ? ? ? ? ? ? cout <<"用户类型:"<<d[i]<<" ?用户名:" << e[i]<<" ?用户密码:" << f[i] << endl; ? ? ? ? } ? ? } }; class Log {//借还日志类 private: ? ? int lend_date;//借书日期 ? ? int return_date;//还书日期 public: ? ? Log(){} ? ? void see(User yonghu)//查看本人借阅信息 ? ? { ? ? ? ? int i; ? ? ? ? int num=0; ? ? ? ? char a[100][20];//图书类型 ? ? ? ? char b[100][20];//编号 ? ? ? ? char c[100][20];//书名 ? ? ? ? char d[100][20];//作者 ? ? ? ? char e[100][20];//出版社 ? ? ? ? char f[100][20];//价格 ? ? ? ? char people[100][20];//借书人 ? ? ? ? tt p;//借书时间 ? ? ? ? fstream in; ? ? ? ? in.open("Log.text", ios::in); ? ? ? ? for (i = 0;; i++) ? ? ? ? { ? ? ? ? ? ? if (in.eof()) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? num--; ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ?? ??? ??? ?in >> a[i] >> b[i] >> c[i] >> d[i] >> e[i] >> f[i]; ?? ??? ??? ?in >> people[i]; ?? ??? ??? ?in >> p.year >> p.month >> p.day >> p.hours >> p.minutes >> p.seconds; ? ? ? ? ? ? num++; ?? ??? ?} ? ? ? ? in.close(); ? ? ? ? int flag=0;//0为没有借书,1为有借书 ? ? ? ? cout << "以下为您的借阅信息:" << endl; ? ? ? ? for (i = 0; i < num; i++) ? ? ? ? { ? ? ? ? ? ? if (strcmp(people[i],yonghu.name) == 0)//检索到借阅人 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? cout << a[i] << " ?" << b[i] << " ?" << c[i] << " ?" << d[i] << " ?" << e[i] << " ?" << f[i] << " ?" << p.year << "年" << p.month << "月" << p.day << "日" << p.hours << ":" << p.minutes << endl; ? ? ? ? ? ? ? ? flag = 1; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (flag==0) ? ? ? ? ? ? cout << " ?无" << endl; ? ? } ?? ?void lend_book(User yonghu)//借阅图书 ?? ?{ ?? ??? ?int i; ?? ??? ?char a[50];//书名 ?? ??? ?char b[50];//作者 ?? ??? ?int num = 0;//书的数目 ?? ??? ?int x[100];//在架的图书编号 ?? ??? ?char leixing[100][50];//图书类型 ?? ??? ?char c[100][50];//在架的图书书名 ?? ??? ?char d[100][50];//在架的图书作者 ?? ??? ?char e[100][50];//在架的图书出版社 ?? ??? ?char f[100][20];//价格 ?? ??? ?int y[100];//状态 ?? ??? ?cout << "请输入您要借阅的图书书名:" << endl; ?? ??? ?cin >> a; ?? ??? ?cout << "请输入您要借阅的图书作者:" << endl; ?? ??? ?cin >> b; ?? ??? ?fstream in; ?? ??? ?in.open("Book.text", ios::in); ?? ??? ?for (i = 0;; i++)//找要借阅的书 ?? ??? ?{ ?? ??? ??? ?if (in.eof()) ?? ??? ??? ?{ ?? ??? ??? ??? ?num--; ?? ??? ??? ??? ?break; ?? ??? ??? ?} ?? ??? ??? ?in >> leixing[i] >> x[i] >> c[i] >> d[i] >> e[i] >> f[i] >> y[i]; ?? ??? ??? ?num++; ?? ??? ?} ?? ??? ?in.close(); ?? ??? ?cout << "查询到以下图书:" << endl; ?? ??? ?int flag = 0;//0为未查到书,1为查到书 ?? ??? ?for (i = 0; i < num; i++) ?? ??? ?{ ?? ??? ??? ?if (strcmp(a, c[i]) == 0 && strcmp(b, d[i]) == 0) ?? ??? ??? ?{ ?? ??? ??? ??? ?cout << " ? " << leixing[i] << " ?编号:" << x[i] << " ?" << c[i] << " ?" << d[i] << " ?" << e[i] << " ?" << f[i] << " ?"; ?? ??? ??? ??? ?if (y[i] == 1) ?? ??? ??? ??? ??? ?cout << "在架可借" << endl; ?? ??? ??? ??? ?if (y[i] == 0) ?? ??? ??? ??? ??? ?cout << "已借出" << endl; ?? ??? ??? ??? ?flag = 1; ?? ??? ??? ?} ?? ??? ?} ?? ??? ?if (flag == 0)//未检索到书 ?? ??? ?{ ?? ??? ??? ?cout << " ? 无" << endl; ?? ??? ??? ?cout << "未查询到此书!" << endl; ?? ??? ?} ?? ??? ?if (flag == 1)//检索到书 ?? ??? ?{ ? ? ? ? ? ? int flag2=1;//0借阅失败,1为借阅成功 ?? ??? ??? ?int bianhao; ?? ??? ??? ?cout << "请输入您要借阅的图书编号:" << endl; ?? ??? ??? ?cin >> bianhao; ?? ??? ??? ?for (i = 0; i < num; i++) ?? ??? ??? ?{ ?? ??? ??? ??? ?if (bianhao == x[i]&&y[i]==1)//找到书且书可借 ?? ??? ??? ??? ?{ ?? ??? ??? ??? ??? ?y[i]=0; ? ? ? ? ? ? ? ? ? ? break; ?? ??? ??? ??? ?} ? ? ? ? ? ? ? ? if (bianhao == x[i] && y[i] == 0)//找到书且书已借出 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? cout << "无法借阅,该书已被借出!" << endl; ? ? ? ? ? ? ? ? ? ? flag2 = 0; ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ?? ??? ??? ?} ? ? ? ? ? ? if (i == num)//未检索到图书 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? flag2 = 0; ? ? ? ? ? ? ? ? cout << "未查询到该图书!" << endl; ? ? ? ? ? ? } ? ? ? ? ? ? if(flag2==1)//借阅成功 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? fstream out; ? ? ? ? ? ? ? ? out.open("Book.text", ios::out); ? ? ? ? ? ? ? ? for (i = 0; i < num; i++) ? ? ? ? ? ? ? ? ? ? out << setiosflags(ios::left) << setw(15) << leixing[i] << setw(15) << x[i] << setw(20) << c[i] << setw(20) << d[i] << setw(20) << e[i] << setw(20) << f[i] << setw(5) << y[i] << endl; ? ? ? ? ? ? ? ? out.close(); ? ? ? ? ? ? ? ? tt p; ? ? ? ? ? ? ? ? p = system_time();//p存储了当前系统时间 ? ? ? ? ? ? ? ? fstream out2; ? ? ? ? ? ? ? ? out2.open("Log.text", ios::app); ? ? ? ? ? ? ? ? for (i = 0; i < num; i++) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? if (bianhao == x[i]) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? out2 << setiosflags(ios::left) << setw(15) << leixing[i] << setw(15) << x[i] << setw(20) << c[i] << setw(20) << d[i] << setw(20) << e[i] << setw(20) << f[i]; ? ? ? ? ? ? ? ? ? ? ? ? out2 << yonghu.name << " ?"; ? ? ? ? ? ? ? ? ? ? ? ? out2 << p.year << " " << p.month << " " << p.day << " " << p.hours << " " << p.minutes << " " << p.seconds << endl; ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? out2.close(); ? ? ? ? ? ? ? ? cout << "借阅成功!" << endl; ? ? ? ? ? ? } ?? ??? ?} ?? ?} ? ? void return_book(int n,User yonghu)//n:1为读者,2为图书管理员,3为系统管理员 ? ? { ? ? ? ? int i; ? ? ? ? int num = 0;//图书数量 ? ? ? ? int x[100];//图书编号 ? ? ? ? char leixing[100][50];//图书类型 ? ? ? ? char c[100][50];//图书书名 ? ? ? ? char d[100][50];//图书作者 ? ? ? ? char e[100][50];//图书出版社 ? ? ? ? char f[100][20];//价格 ? ? ? ? int y[100];//状态 ? ? ? ? fstream in; ? ? ? ? in.open("Book.text", ios::in); ? ? ? ? for (i = 0;; i++)//找要还的书 ? ? ? ? { ? ? ? ? ? ? if (in.eof()) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? num--;// ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? ? ? in >> leixing[i] >> x[i] >> c[i] >> d[i] >> e[i] >> f[i] >> y[i]; ? ? ? ? ? ? num++;// ? ? ? ? } ? ? ? ? in.close(); ? ? ? ? see(yonghu);//输出该用户借阅图书信息 ? ? ? ? int bianhao; ? ? ? ? cout << "请输入您要返还图书的编号:" << endl; ? ? ? ? cin >> bianhao; ? ? ? ? for (i = 0; i < num; i++)//改变图书状态 ? ? ? ? { ? ? ? ? ? ? if (bianhao == x[i])//找到图书 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? y[i] = 1;//改变图书状态为在架可借 ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (i == num)//未查询到图书 ? ? ? ? { ? ? ? ? ? ? cout << "未查询到该图书!" << endl; ? ? ? ? } ? ? ? ? else//查询到图书 ? ? ? ? { ? ? ? ? ? ? fstream out; ? ? ? ? ? ? out.open("Book.text", ios::out); ? ? ? ? ? ? for (i = 0; i < num; i++)//更新book文件 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? out << setiosflags(ios::left) << setw(15) << leixing[i] << setw(15) << x[i] << setw(20) << c[i]; ? ? ? ? ? ? ? ? out << setw(20) << d[i] << setw(20) << e[i] << setw(20) << f[i] << setw(5) << y[i] << endl; ? ? ? ? ? ? } ? ? ? ? ? ? out.close(); ? ? ? ? ? ? ? //更改Log.text ? ? ? ? ? ? int x2[100];//已借阅的的图书编号 ? ? ? ? ? ? char leixing2[100][50];//已借阅图书的图书类型 ? ? ? ? ? ? char c2[100][50];//已借阅图书的图书书名 ? ? ? ? ? ? char d2[100][50];//已借阅图书的图书作者 ? ? ? ? ? ? char e2[100][50];//已借阅图书的图书出版社 ? ? ? ? ? ? char f2[100][50];//已借阅图书的价格 ? ? ? ? ? ? char person[50];//借书者用户名 ? ? ? ? ? ? tt time1[100];//借书时间 ? ? ? ? ? ? tt time2 = system_time();//还书时间 ? ? ? ? ? ? int log_num = 0; ? ? ? ? ? ? fstream in2; ? ? ? ? ? ? in2.open("Log.text", ios::in); ? ? ? ? ? ? for (i = 0;; i++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (in2.eof()) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? log_num--; ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? in2 >> leixing2[i] >> x2[i] >> c2[i] >> d2[i] >> e2[i] >> f2[i] >> person; ? ? ? ? ? ? ? ? in2>> time1[i].year >> time1[i].month >> time1[i].day >> time1[i].hours >> time1[i].minutes >> time1[i].seconds; ? ? ? ? ? ? ? ? log_num++;// ? ? ? ? ? ? } ? ? ? ? ? ? in2.close(); ? ? ? ? ? ? int del;//还的书的序号 ? ? ? ? ? ? for (i = 0; i < log_num; i++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (bianhao == x2[i]) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? del = i; ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? fstream out2; ? ? ? ? ? ? out2.open("Log.text", ios::out); ? ? ? ? ? ? for (i = 0; i < log_num; i++)//向文件输出新的Log ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (i == del) ? ? ? ? ? ? ? ? ? ? continue; ? ? ? ? ? ? ? ? out2 << setiosflags(ios::left) << setw(15) << leixing2[i] << setw(15) << x2[i]; ? ? ? ? ? ? ? ? out2<< setw(20) << c2[i] << setw(20) << d2[i] << setw(20) << e2[i] << setw(20) << f2[i]; ? ? ? ? ? ? ? ? out2 << yonghu.name << " ?"; ? ? ? ? ? ? ? ? out2 << time1[i].year << " " << time1[i].month << " " << time1[i].day << " "; ? ? ? ? ? ? ? ? out2<< time1[i].hours << " " << time1[i].minutes << " " << time1[i].seconds << endl; ? ? ? ? ? ? } ? ? ? ? ? ? out2.close(); ? ? ? ? ? ? //判断是否超出还书时间 ? ? ? ? ? ? int deadline; ? ? ? ? ? ? if (n == 1)//读者 ? ? ? ? ? ? ? ? deadline = 14;//读者借书期限为14天 ? ? ? ? ? ? if (n == 2 || n == 3)//图书管理员或系统管理员 ? ? ? ? ? ? ? ? deadline = 21;//管理员借书期限为21天 ? ? ? ? ? ? if (time2.year - time1[del].year > 0 || time2.month - time1[del].month > 0 || time2.day - time1[del].day > deadline) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? cout << "您已超出图书归还日期,请到办公室缴纳罚款" << endl; ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? ? ? cout << "还书成功!" << endl; ? ? ? ? } ?? ?} }; int main() { ? ? char kouling1[50] = "123456"; ? ? cout << "——————图书管理系统——————" << endl; ? ? int i,j; ? ? Book shu[100];//图书 ? ? Reader duzhe[100];//读者 ? ? Librarian tushu[100];//图书管理员 ? ? System_Admin xitong[100];//系统管理员 ? ? Log rizhi[100];//借还书日志 ? ? int flag;//0为没有用户登录,1为已有用户登录 ? ? for (i = 0;; i++) ? ? { ? ? ? ? if(i!=0) ? ? ? ? ? ? cout << "————主界面————" << endl; ? ? ? ? cout << "1.注册" << endl; ? ? ? ? cout << "2.登录" << endl; ? ? ? ? cout << "3.退出" << endl; ? ? ? ? int n;//1为注册,2为登录,3为退出系统 ? ? ? ? cin >> n; ? ? ? ? if (n == 1)//注册 ? ? ? ? { ? ? ? ? ? ? cout << "请选择您要注册的用户类型" << endl; ? ? ? ? ? ? cout << "1.读者" << endl; ? ? ? ? ? ? cout << "2.图书管理员" << endl; ? ? ? ? ? ? cout << "3.系统管理员" << endl; ? ? ? ? ? ? cout << "4.返回上一层菜单" << endl; ? ? ? ? ? ? int m;//1为注册读者,2为注册图书管理员,3为注册系统管理员 ? ? ? ? ? ? cin >> m; ? ? ? ? ? ? if (m == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? duzhe[i].zhuce();//注册读者 ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? for (;;) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? char kl[20];//图书管理员口令 ? ? ? ? ? ? ? ? ? ? cout << "请输入图书管理员口令:" << endl; ? ? ? ? ? ? ? ? ? ? cin >> kl;//接收口令 ? ? ? ? ? ? ? ? ? ? if (strcmp(kl,kouling1) == 0) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].zhuce();//注册图书管理员 ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? cout << "口令错误,请输入正确口令!" << endl; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 3) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? for (;;) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? char k2[20];//系统管理员口令 ? ? ? ? ? ? ? ? ? ? cout << "请输入系统管理员口令:" << endl; ? ? ? ? ? ? ? ? ? ? cin >> k2;//接收口令 ? ? ? ? ? ? ? ? ? ? if (strcmp(k2, kouling2) == 0) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].zhuce();//注册系统管理员 ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? cout << "口令错误,请输入正确口令!" << endl; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 4) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? continue; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (n == 2)//登录界面 ? ? ? ? { ? ? ? ? ? ? cout << "请选择您要登录的用户类型" << endl; ? ? ? ? ? ? cout << "1.读者" << endl; ? ? ? ? ? ? cout << "2.图书管理员" << endl; ? ? ? ? ? ? cout << "3.系统管理员" << endl; ? ? ? ? ? ? cout << "4.返回上一层菜单" << endl; ? ? ? ? ? ? int m; ? ? ? ? ? ? cin >> m; ? ? ? ? ? ? if (m == 1) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? flag=duzhe[i].denglu("读者"); ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 2) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? flag=tushu[i].denglu("图书管理员"); ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 3) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? flag=xitong[i].denglu("系统管理员"); ? ? ? ? ? ? } ? ? ? ? ? ? if (m == 4) ? ? ? ? ? ? ? ? continue; ? ? ? ? ? ? if (flag == 1)//登录成功 ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (m == 1)//读者登录 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? for (;;) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? int x; ? ? ? ? ? ? ? ? ? ? ? ? cout << "————读者界面————" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.修改用户名" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.修改密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "3.借阅图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "4.还书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "5.本人借阅信息查看" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "6.退出账号" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cin >> x; ? ? ? ? ? ? ? ? ? ? ? ? if (x == 1) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_name[20];//改后的用户名 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? duzhe[i].change_information(after_name,1); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 2) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_password[20];//改后的密码 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_password; ? ? ? ? ? ? ? ? ? ? ? ? ? ? duzhe[i].change_information(after_password,2); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 3) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].lend_book(duzhe[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 4) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].return_book(1,duzhe[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 5) ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].see(duzhe[i]); ? ? ? ? ? ? ? ? ? ? ? ? if (x == 6) ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? if (m == 2)//登录的为图书管理员 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? for (;;) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? int x; ? ? ? ? ? ? ? ? ? ? ? ? cout << "————图书管理员界面————" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.修改用户名" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.修改密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "3.借阅图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "4.还书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "5.本人借阅信息查看" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "6.增加图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "7.修改图书信息" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "8.删除图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "9.查看用户借阅信息" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "10.退出账号" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cin >> x; ? ? ? ? ? ? ? ? ? ? ? ? if (x == 1) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_name[20];//改后的用户名 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].change_information(after_name, 1); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 2) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_password[20];//改后的密码 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_password; ? ? ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].change_information(after_password, 2); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 3) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].lend_book(tushu[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 4) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].return_book(2, tushu[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 5) ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].see(tushu[i]); ? ? ? ? ? ? ? ? ? ? ? ? if (x == 6) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? int y;//1为纸质图书,2为碟片,3为电子资源 ? ? ? ? ? ? ? ? ? ? ? ? ? ? int no1;//编号 ? ? ? ? ? ? ? ? ? ? ? ? ? ? char name1[20];//书名 ? ? ? ? ? ? ? ? ? ? ? ? ? ? char author1[20];//作者 ? ? ? ? ? ? ? ? ? ? ? ? ? ? char press1[20];//出版社 ? ? ? ? ? ? ? ? ? ? ? ? ? ? char price1[10];//价格 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要增加的图书类型:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.纸质图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.碟片" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "3.电子资源" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入图书编号:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> no1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (shu[i].chongfu_no(no1) == 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? continue; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入书名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> name1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入作者:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> author1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入出版社:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> press1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入图书价格" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> price1; ?? ??? ??? ??? ??? ??? ??? ?if (y == 1) ?? ??? ??? ??? ??? ??? ??? ??? ?tushu[i].add_book(no1, name1, author1, press1, price1, 1); ?? ??? ??? ??? ??? ??? ??? ?if (y == 2) ?? ??? ??? ??? ??? ??? ??? ??? ?tushu[i].add_book(no1, name1, author1, press1, price1, 2); ?? ??? ??? ??? ??? ??? ??? ?if (y == 3) ?? ??? ??? ??? ??? ??? ??? ??? ?tushu[i].add_book(no1, name1, author1, press1, price1, 3); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 7) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? int y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要修改图书的编号:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].change_book(y); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 8) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? int y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要删除图书的编号:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].delete_book(y); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 9) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? tushu[i].see_all(); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 10) ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? if (m == 3)//登录的为系统管理员 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? for (;;) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? int x; ? ? ? ? ? ? ? ? ? ? ? ? cout << "————系统管理员界面————" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.修改用户名" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.修改密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "3.借阅图书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "4.还书" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "5.本人借阅信息查看" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "6.修改图书管理员口令" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "7.增加用户" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "8.删除用户" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "9.修改用户信息" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "10.查看用户信息" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cout << "11.退出账号" << endl; ? ? ? ? ? ? ? ? ? ? ? ? cin >> x; ? ? ? ? ? ? ? ? ? ? ? ? if (x == 1) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_name[20];//改后的用户名 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].change_information(after_name, 1); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 2) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char after_password[20];//改后的密码 ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入新的密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> after_password; ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].change_information(after_password, 2); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 3) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].lend_book(xitong[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 4) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].return_book(3,xitong[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 5) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? rizhi[i].see(xitong[i]); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 6) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char kouling3[50]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入修改后的图书管理员口令:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> kouling3; ? ? ? ? ? ? ? ? ? ? ? ? ? ? memset(kouling1, '\0', sizeof(kouling1)); ? ? ? ? ? ? ? ? ? ? ? ? ? ? strcmp(kouling1, kouling3); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 7) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? int y;//1为读者,2为图书管理员 ? ? ? ? ? ? ? ? ? ? ? ? ? ? char name[50]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? char password[50]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要增加的用户类型:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.读者" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.图书管理员" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入密码:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> password; ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].add_User(name,password,y); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 8) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char name[50]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要删除用户的用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].delete_user(name); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 9) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? char name[50]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要修改用户的用户名:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> name; ? ? ? ? ? ? ? ? ? ? ? ? ? ? int y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "请输入您要修改用户的哪个信息:" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "1.用户类型" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "2.用户名" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout << "3.用户密码" << endl; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cin >> y; ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].change_user(name,y); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 10) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? xitong[i].see_user(); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? if (x == 11) ? ? ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? if (n == 3) ? ? ? ? ? ? return 0; ? ? } ? ? return 0; }

实验结果展示

注册成功后用户信息会写入文件中,这样关闭程序后用户信息不会丢失

用户信息

三个text文件分别保存书籍信息(Book)、借阅信息(Log)、用户信息(User)

书籍信息

借阅信息

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

相关文章阅读

  • c语言调用退出函数 c语言退出整个程序怎么写
  • c语言中怎么给函数初始化 c语言的初始化语句
  • c语言编写函数计算平均值 c语言求平均函数
  • 详解c语言中的字符串数组是什么,详解c语言中的字符串数组结构,详解C语言中的字符串数组
  • 表达式求值c++实现,c语言实现表达式求值
  • 看懂c语言基本语法,C语言详解,C语言的基本语法详解
  • 用c语言实现快速排序算法,排序算法设计与实现快速排序C语言,C语言实现快速排序算法实例
  • 深入解析c语言中函数指针的定义与使用方法,深入解析c语言中函数指针的定义与使用情况,深入解析C语言中函数指针的定义与使用
  • 描述E-R图,E-R图举例,关于C语言中E-R图的详解
  • 折半查找法C语言,折半查找算法(算法设计题)
  • 折半查找法C语言,c语言折半法查找数据,C语言实现折半查找法(二分法)
  • 扫雷小游戏c++代码设计,c语言扫雷游戏源代码,C语言实现扫雷小游戏详细代码
  • 怎样统计程序代码行数,C语言统计行数,C#程序员统计自己的代码行数
  • 基于c语言的贪吃蛇游戏程序设计,用c语言编写贪吃蛇游戏程序,C语言实现简单的贪吃蛇游戏
  • 图的两种遍历算法,图的遍历算法代码c语言,Python算法之图的遍历
  • 留言与评论(共有 条评论)
       
    验证码: