C语言图书管理系统论文Word格式文档下载.docx
- 文档编号:5011581
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:30
- 大小:211.71KB
C语言图书管理系统论文Word格式文档下载.docx
《C语言图书管理系统论文Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C语言图书管理系统论文Word格式文档下载.docx(30页珍藏版)》请在冰点文库上搜索。
{否
intbooknum;
//书号
charbookname[20];
//书名
charauthor[10];
//作者
intbookcount;
//书的剩余数量是
}book[1000];
structcard/*借书卡的数据类型*/
charstudentname[10];
//会员姓名
charstudentclass[10];
//会员班级
}card[1000];
2.2主函数
主函数要求设计比较简洁,只提供设输入,处理和输出部分的函数调用。
其中各功能模块用菜单方式选择。
HWNDhwnd=GetForegroundWindow();
SetWindowText(hwnd,"
★图书管理系统★"
);
intch1,ch2,ch3;
do
{SetConsoleTextAttribute(h,FOREGROUND_RED);
//设置字体颜色为红色
printf("
\n\t\t★欢★迎★进★入★图★书★管★理★系★统★\n\n"
\t※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n"
\t※※\n"
\t※★图书管理系统★※\n"
\t※1:
<
借书系统>
2:
还书系统>
※\n"
\t※3:
会员管理>
4:
书籍管理>
printf("
\t※0:
退出>
\t※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n\n\n"
\t\t请选择操作类型(0-4):
"
scanf("
%d"
&
ch1);
switch(ch1)
{case1:
lendbook();
break;
case2:
returnbook();
case3:
{
do
{SetConsoleTextAttribute(h,FOREGROUND_GREEN);
//设置字体颜色为绿色
\n\n"
\t※★欢迎进入会员管理系统★※\n"
申请新卡>
删除卡号>
借书统计>
会员统计>
返回>
scanf("
ch3);
switch(ch3)
{case1:
addcard();
delcard();
lendcount();
case4:
cardcount();
case0:
default:
\n\t\t无效操作,按任意键返回...\n"
getch();
}
}while(ch3!
=0);
}break;
case4:
do{
SetConsoleTextAttribute(h,FOREGROUND_GREEN);
\t※★欢迎进入书籍管理系统★※\n"
printf("
增加图书>
删除图书>
查询图书>
书籍统计>
\t※5:
修改图书资料>
0:
返回主菜单>
\t\t请选择操作类型(0-5):
scanf("
ch2);
switch(ch2)
addbook();
delbook();
searchbook();
bookcount();
case5:
modifybook();
}while(ch2!
case0:
default:
}
}while(ch1!
2.3借书模块流程图
voidlendbook()
{//借书功能函数
HANDLEh=GetStdHandle(STD_OUTPUT_HANDLE);
FILE*fp,*fp2;
inti,n;
\n\t\t请你输入你的卡号:
"
cardnum);
fp=fopen("
card.txt"
"
r"
for(i=0;
fread(&
card[i],sizeof(structcard),1,fp)!
=0;
i++)否
{
if(card[i].cardnum==cardnum)
{是
n=i;
fclose(fp);
\n\t\t请输入你要借阅的书的名字:
%s"
student[n].lendbook);
fp=fopen("
book.txt"
否
for(i=0;
book[i],sizeof(structbook),1,fp)!
i++)
{
if(strcmp(book[i].bookname,student[n].lendbook)==0)是
{
if(book[i].bookcount==0)
{
printf("
\t\t对不起,此书有人借出,请借其他书.按任意键返回...\n"
fclose(fp);
getch();
return;
}else{
//book[i].bookcount--;
}
fp=fopen("
record.txt"
a+"
//以读写方式打开record.txt
student[n].cardnum=cardnum;
fwrite(&
student[n],sizeof(structstudent),1,fp);
fclose(fp);
fp2=fopen("
booktemp.txt"
w"
for(i=0;
{
if(strcmp(book[i].bookname,student[n].lendbook)==0)
{
book[i].bookcount--;
fwrite(&
book[i],sizeof(structbook),1,fp2);
continue;
}
fwrite(&
fclose(fp2);
book[i],sizeof(structbook),1,fp2)!
book[i],sizeof(structbook),1,fp);
fopen("
printf("
\n\t\t借书完毕,按任意键返回..."
getch();
return;
}
}
\n\t\t很抱歉,不存在这本书,按任意键返回..."
getch();
return;
\n\t\t你的卡号不存在,请申请新卡,按任意键返回..."
fclose(fp);
getch();
2.4还书模块
voidreturnbook()/*还书函数*/
/*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/
inti,temp;
intcardexit=0,bookexit=0;
//卡号书籍是否存在(借阅)标志存在(借阅)为1不存在为0
/*读取卡号记录*/
i++)/*for循环判断卡号是否存在*/
if(card[i].cardnum==cardnum)/*卡号存在,进入下一循环*/
{
cardexit=1;
temp=i;
\n\t\t请输入你要还的书的名字:
lendbook);
student[i],sizeof(structstudent),1,fp)!
i++)/*判断是否借阅了输入的书*/
if(student[i].lendbook==lendbook)/*借阅了该书,进入下一循环,否则出错显示*/
bookexit=1;
fclose(fp);
fp=fopen("
fp2=fopen("
for(i=0;
if(student[i].lendbook==lendbook)
continue;
/*删除还掉的书的借书记录*/
fwrite(&
student[i],sizeof(structstudent),1,fp2);
/*写入原来没还的书的记录*/
fclose(fp2);
student[i],sizeof(structstudent),1,fp2)!
student[i],sizeof(structstudent),1,fp);
/*将借书记录信息写回*/
fopen("
/*清临时文件的记录*/
i++)/*将书的记录写入临时文件,防止因为修改信息破坏以前的记录*/
if(i==temp)
book[i].bookcount++;
fwrite(&
/*将还的书的可借数量加1*/
continue;
/*将临时文件写回*/
/*清临时文件*/
printf("
\n\t\t还书完毕,按任意键返回...\n"
}
if(cardexit==0)
\n\t\t系统没此卡号,请和管理员联系,按任意键返回...\n"
/*出错提示*/
elseif(bookexit==0)
\n\t\t你没有借这本书,按任意键返回...\n"
/*出错提示*/
2.5会员管理模块
会员管理有四个功能:
申请新卡、删除卡号、借书统计、卡号统计,分别对应以下四个函数:
voidaddcard()
{//增加新卡函数
FILE*fp;
inti=0,tempcard,temp=0;
\n\t\t请输入卡号:
tempcard);
i++)//判断卡号是否存在
if(tempcard==card[i].cardnum)
temp=1;
if(temp==1)//如果卡号存在,返回
\n\t\t此卡号已经存在,按任意键返回..."
elseif(temp==0){//如果卡号不存在,继续下面操作
card[i].cardnum=tempcard;
\n\t\t请输入学生姓名:
card[i].studentname);
\n\t\t请输入班级:
card[i].studentclass);
fwrite(&
card[i],sizeof(structcard),1,fp);
\n\t\t输入完毕,任意键返回...\n"
voiddelcard()
{//删除卡号记录函数
inti;
charchoice;
fp2=fopen("
\n\t\t提示:
如果你输入的卡号存在,系统自动删除该信息."
\n\t\t如果不存在,系统不做任何改动."
\n\t\t请输入你要删除的卡号:
if(card[i].cardnum!
=cardnum)
card[i],sizeof(structcard),1,fp2);
fclose(fp2);
\n\t\t是否真的要删除该卡?
删除后该书籍的所有信息将无法恢复<
Y/N>
:
choice);
if(choice=='
y'
||choice=='
Y'
)
card[i],sizeof(structcard),1,fp2)!
\t\t按任意键返回...\n"
else
intlendcount()
{//会员借书统计函数
inti,n=0;
\t\t卡号:
%d借出的书籍:
%s\n"
student[i].cardnum,student[i].lendbook);
n=n+1;
\t\t目前共有%d本书借出\n"
n);
returnn;
voidcardcount()
{//会员卡号统计函数
\t\t卡号姓名班级\n"
\n\t\t%-10d%-10s%-2s\n"
card[i].cardnum,card[i].studentname,card[i].studentclass);
\n\t\t目前共有%d个会员\n"
2.6书籍管理模块
书籍管理模块有五个功能
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 图书 管理 系统 论文
![提示](https://static.bingdoc.com/images/bang_tan.gif)