图书管理c语言版.docx
- 文档编号:23617938
- 上传时间:2023-05-19
- 格式:DOCX
- 页数:65
- 大小:24.71KB
图书管理c语言版.docx
《图书管理c语言版.docx》由会员分享,可在线阅读,更多相关《图书管理c语言版.docx(65页珍藏版)》请在冰豆网上搜索。
图书管理c语言版
#include
#include
#include
structtushu{/*图书结构体*/
charnum[10];/*编号*/
charname[20];/*书名*/
charwriter[20];/*作者*/
charpress[20];/*出版社*/
charkind[20];/*类别*/
doubletime;/*时间*/
doubleprice;/*价格*/
structtushu*next;
};
structstu/*学生结构体*/
{
intsnum;/*学号*/
charmima[10];/*密码*/
structstu*next;
};
FILE*fp;/*图书文件*/
FILE*fp1;/*管理员信息文件*/
FILE*fp2;/*学生信息文件*/
voidmenu();/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/
voidxmenu();/*学生主菜单(学生进入可对图书,密码进行操作)*/
voidgfind();/*管理员查询(管理员可按一定的方式查询图书)*/
voidxfind();/*学生查询(学生可按一定的方式查询图书)*/
voidsecret();/*管理员权限(管理员登陆所用,输入错误次数过多自动退出)*/
voidsort();/*排序(管理员可按一定的方式对图书进行排序,排序完之后可选择文件进行保存)*/
voidfprint(structtushu*head);/*保存(可追加的保存,如添加可用)*/
voidfprint_(structtushu*head);/*保存(可覆盖保存如修改,删除,排序后用)*/
voidhfprint(structtushu*head);/*还书保存(还书成功后自动保存到文件)*/
voidjfprint_(structtushu*head);/*借书保存(借书成功之后自动从图书馆删除)*/
structtushu*Input();/*图书添加(可进行图书的添加)*/
structtushu*create();/*从文件创建链表(从文件中读出信息,建立单链表)*/
voidgBrowse(structtushu*head);/*管理员浏览(对图书进行遍历)*/
voidxBrowse(structtushu*head);/*学生浏览(学生对图书进行遍历)*/
voidcount(structtushu*head);/*统计数量(管理员可对图书进行统计)*/
voidFindofname(structtushu*head);/*按书名查找*/
voidFindofwriter(structtushu*head);/*按作者查找*/
voidFindofkind(structtushu*head);/*按类别查找*/
voidxFindofname(structtushu*head);/*学生按书名查找*/
voidxFindofwriter(structtushu*head);/*学生按作者查找*/
voidxFindofkind(structtushu*head);/*学生按类别查找*/
voidSort_time(structtushu*head);/*按时间排序(管理员按时间对图书进行排序,排序完之后可选择文件进行保存)*/
voidSort_price(structtushu*head);/*按价格排序*/
voidSort_num(structtushu*head);/*按编号排序*/
voidDelete(structtushu*head,charm[15]);/*按编号删除(管理员可按编号删除图书)*/
voidRevise(structtushu*head);/*修改(管理员可对图书进行修改,并选择是否保存)*/
voidborrow(structtushu*head);/*借书*/
voidhuanshu();/*还书(学生借完书之后进行还书,若没有图书则不能借)*/
voidgxinxi();/*管理员信息(有管理员的账号及密码,可进行修改)*/
voidxmima(structstu*head1);/*学生密码修改(学生可对自己的密码进行修改)*/
structstu*xcreate();/*从文件创建学生信息(从文件读出学生信息,建立学生链表)*/
voidxsecret(structstu*head1);/*学生权限(学生登陆所用)*/
voidmenu()/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/
{
intchoice,n=0;
structtushu*head;
structstu*head1,*p;
charm[15];
there:
printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf("┃┃socat图书管理系统┃┃\n");
printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");
printf("┃●[0]退出系统┃\n");
printf("┃┃\n");
printf("┃●[1]帮助┃\n");
printf("┃┃\n");
printf("┃●[2]浏览图书┃\n");
printf("┃┃\n");
printf("┃●[3]统计图书数目┃\n");
printf("┃┃\n");
printf("┃●[4]查询┃\n");
printf("┃┃\n");
printf("┃●[5]添加┃\n");
printf("┃┃\n");
printf("┃●[6]排序┃\n");
printf("┃┃\n");
printf("┃●[7]修改┃\n");
printf("┃┃\n");
printf("┃●[8]删除┃\n");
printf("┃┃\n");
printf("┃●[9]修改账号及密码┃\n");
printf("┃┃\n");
printf("┃●[10]学生信息┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择:
");
fflush(stdin);
head=create();
scanf("%d",&choice);
if(choice==1)
{
//help();
printf("没有内容!
\n");
system("pause");
system("cls");
menu();
}
elseif(choice==2)
{
system("cls");
if(head==NULL)
{
printf("没有图书,请先添加图书!
\n");
system("pause");
system("cls");
menu();
}
gBrowse(head);
}
elseif(choice==3)
{
system("cls");
count(head);
}
elseif(choice==4)
{
system("cls");
if(head==NULL)
{
printf("没有图书,请先添加图书!
\n");
system("pause");
system("cls");
menu();
}
gfind();
}
elseif(choice==5)
{
Input();
}
elseif(choice==6)
{
system("cls");
if(head==NULL)
{
printf("没有图书,请先添加图书!
\n");
system("pause");
system("cls");
menu();
}
sort(head);
}
elseif(choice==7)
{
system("cls");
if(head==NULL)
{
printf("没有图书,请先添加图书!
\n");
system("pause");
system("cls");
menu();
}
Revise(head);
}
elseif(choice==8)
{
if(head==NULL)
{
printf("没有图书,请先添加图书!
\n");
system("pause");
system("cls");
menu();
}
printf("请输入想要删除的图书编号:
");
scanf("%s",m);
Delete(head,m);
}
elseif(choice==9)
{
gxinxi();
}
elseif(choice==10)
{
system("cls");
head1=xcreate();
if(head1==NULL)
{
printf("没有学生信息,请到xuesheng_list.txt添加!
\n");
system("pause");
system("cls");
menu();
}
for(p=head1;p!
=NULL;p=p->next)
{
printf("学生学号密码\n");
printf("%d%s\n",p->snum,p->mima);
}
system("pause");
system("cls");
menu();
}
elseif(choice==0)
{
system("cls");
printf("\n\n\n\n");
printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");
exit(0);
}
else
{
system("cls");
printf("\n\n\n\n━━━━输入错误,请重新输入!
━━━━\n\n\n");
system("pause");
system("cls");
n++;
if(n==3)
{
printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!
━━━━━━━━\n\n\n");
printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");
system("pause");
exit(0);
}
gotothere;
}
}
voidxmenu()/*学生主菜单(学生进入可对图书,密码进行操作)*/
{
structtushu*head;
structstu*head1;
intchoice,n=0;
there:
printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf("┃┃socat图书借阅系统┃┃\n");
printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");
printf("┃●[0]退出系统┃\n");
printf("┃┃\n");
printf("┃●[1]帮助┃\n");
printf("┃┃\n");
printf("┃●[2]浏览图书┃\n");
printf("┃┃\n");
printf("┃●[3]查询┃\n");
printf("┃┃\n");
printf("┃●[4]借书┃\n");
printf("┃┃\n");
printf("┃●[5]还书┃\n");
printf("┃┃\n");
printf("┃●[6]修改密码┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择:
");
fflush(stdin);
head=create();
scanf("%d",&choice);
if(choice==1)
{
//xhelp();
printf("没有内容!
\n");
system("pause");
system("cls");
xmenu();
}
elseif(choice==2)
{
system("cls");
if(head==NULL)
{
printf("没有图书!
\n");
system("pause");
system("cls");
xmenu();
}
xBrowse(head);
}
elseif(choice==3)
{
if(head==NULL)
{
printf("没有图书!
\n");
system("pause");
system("cls");
xmenu();
}
xfind();
}
elseif(choice==4)
{
if(head==NULL)
{
printf("没有图书!
\n");
system("pause");
system("cls");
xmenu();
}
borrow(head);
}
elseif(choice==5)
{
huanshu(head);
}
elseif(choice==6)
{
system("cls");
head1=xcreate();
if(head1==NULL)
{
printf("学生信息被清空!
!
\n");
system("pause");
system("cls");
xmenu();
}
xmima(head1);;
}
elseif(choice==0)
{
system("cls");
printf("\n\n\n\n");
printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");
exit(0);
}
else
{
system("cls");
printf("\n\n\n\n━━━━输入错误,请重新输入!
━━━━\n\n\n");
system("pause");
system("cls");
n++;
if(n==3)
{
printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!
━━━━━━━━\n\n\n");
printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");
system("pause");
exit(0);
}
gotothere;
}
}
voidgfind()/*管理员查询(管理员可按一定的方式查询图书)*/
{
intchoice,n=0;
structtushu*head;
there:
system("cls");
printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf("┃┃socat图书借阅系统┃┃\n");
printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");
printf("┃●[0]返回┃\n");
printf("┃┃\n");
printf("┃●[1]按书名查找┃\n");
printf("┃┃\n");
printf("┃●[2]按作者查找┃\n");
printf("┃┃\n");
printf("┃●[3]按类别查找┃\n");
printf("┃┃\n");
printf("┃●┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择:
");
fflush(stdin);
head=create();
scanf("%d",&choice);
if(choice==1)
{
system("cls");
Findofname(head);
}
elseif(choice==2)
{
system("cls");
Findofwriter(head);
}
elseif(choice==3)
{
system("cls");
Findofkind(head);
}
elseif(choice==0)
{
system("cls");
menu();
}
else
{
system("cls");
printf("\n\n\n\n━━━━输入错误,请重新输入!
━━━━\n\n\n");
system("pause");
system("cls");
n++;
if(n==3)
{
printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!
━━━━━━━━\n\n\n");
printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");
system("pause");
exit(0);
}
gotothere;
}
}
voidxfind()/*学生查询(学生可按一定的方式查询图书)*/
{
structtushu*head;
intchoice,n=0;
there:
system("cls");
printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf("┃┃socat图书借阅系统┃┃\n");
printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");
printf("┃●[0]返回┃\n");
printf("┃┃\n");
printf("┃●[1]按书名查找┃\n");
printf("┃┃\n");
printf("┃●[2]按作者查找┃\n");
printf("┃┃\n");
printf("┃●[3]按类别查找┃\n");
printf("┃┃\n");
printf("┃●┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择:
");
fflush(stdin);
head=create();
scanf("%d",&choice);
if(choice==1)
{
system("cls");
xFindofname(head);
}
elseif(choice==2)
{
system("cls");
xFindofwriter(head);
}
elseif(choice==3)
{
system("cls");
xFindofkind(head);
}
elseif(choice==0)
{
system("cls");
xmenu();
}
else
{
system("cls");
printf("\n\n\n\n━━━━输入错误,请重新输入!
━━━━\n\n\n");
system("pause");
system("cls");
n++;
if(n==3)
{
printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!
━━━━━━━━\n\n\n");
printf("━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n");
system("pause");
exit(0);
}
gotothere;
}
}
voidsort()
{
structtushu*head;
intchoice,n=0;
there:
system("cls");
printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf("┃┃socat图书借阅系统┃┃\n");
printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");
printf("┃●[0]返回┃\n");
printf("┃┃\n");
printf("┃●[1]按时间排序┃\n");
printf("┃┃\n");
printf("┃●[2]按价格排序┃\n");
printf("┃┃\n");
printf("┃●[3]按编号排序┃\n");
printf("┃┃\n");
printf("┃●┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择:
");
fflush(stdin);
head=create();
scanf("%d",&choice);
if(choice==1)
{
system("cls");
Sort_time(head);
}
elseif(choice==2)
{
system("cls");
Sort_price(head);
}
elseif(choice==3)
{
system("cls");
Sort_num(head);
}
elseif(choice==0)
{
system("cls");
menu();
}
else
{
system("cls"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图书 管理 语言版