课程设计图书馆借阅管理系统.docx

上传人:b****4 文档编号:11558310 上传时间:2023-03-19 格式:DOCX 页数:25 大小:66.95KB
下载 相关 举报
课程设计图书馆借阅管理系统.docx_第1页
第1页 / 共25页
课程设计图书馆借阅管理系统.docx_第2页
第2页 / 共25页
课程设计图书馆借阅管理系统.docx_第3页
第3页 / 共25页
课程设计图书馆借阅管理系统.docx_第4页
第4页 / 共25页
课程设计图书馆借阅管理系统.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

课程设计图书馆借阅管理系统.docx

《课程设计图书馆借阅管理系统.docx》由会员分享,可在线阅读,更多相关《课程设计图书馆借阅管理系统.docx(25页珍藏版)》请在冰豆网上搜索。

课程设计图书馆借阅管理系统.docx

课程设计图书馆借阅管理系统

#include"stdio.h"

#include"stdlib.h"

#include"conio.h"

#include"string.h"

#include"math.h"

#defineLENsizeof(structlibrary)

#defineLEN1sizeof(structreader)

#defineNULL0

structlibrary//图书馆结构体

{intshuhao,xcl;

charname[20],author[20],chuban[20];

structlibrary*next;

};

structreader//读者结构体

{

intzhenghao;

charmingzi[20],riqi[20],zname[20];

structreader*next;

};

voidmainmenu()//显示主菜单

{system("cls");

printf("********************************************************************************");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("\t\t\t\t1.图书馆信息\n\n");

printf("\t\t\t\t2.借阅系统\n\n");

printf("\t\t\t\t3.退出系统\n\n");

printf("\t\t\t请按键选择,回车确定\n");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("********************************************************************************");

return;

}

voidmenu1()//显示图书馆信息菜单

{system("cls");

printf("********************************************************************************");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("\t\t\t\t1.采编入库\n\n");

printf("\t\t\t\t2.清除库存\n\n");

printf("\t\t\t\t3.图书查询\n\n");

printf("\t\t\t\t4.库存一览\n\n");

printf("\t\t\t\t5.返回上一层\n\n");

printf("\t\t\t请按键选择,回车确定\n");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("********************************************************************************");

return;

}

voidmenu2()//显示查询菜单

{system("cls");

printf("********************************************************************************");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("\t\t\t\t1.书号查询\n\n");

printf("\t\t\t\t2.书名查询\n\n");

printf("\t\t\t\t3.作者查询\n\n");

printf("\t\t\t\t4.出版社查询\n\n");

printf("\t\t\t请按键选择,回车确定\n");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("********************************************************************************");

return;

}

voidmain()//主函数,调用main1

{voidmain1();

main1();}

voidmain1()//main1函数

{voidtsgxx();//声明

voidjieshuxitong();//声明

charchoose;

mainmenu();

scanf("%c",&choose);

switch(choose)//功能函数选择

{case'1':

tsgxx();break;

case'2':

jieshuxitong();break;

case'3':

system("cls");printf("\n\n\n\n\n\n\n\n\n\t\t\tByebye...");printf("\n\n\n\n\n\n\n\n\n\t\t\t欢迎使用本软件");getch();exit(0);system("cls");break;

}

}

voidtsgxx()//图书馆信息函数

{voidtsjinku();

voidshanchu();

voidchaxunts();

voidxianshikucun();//函数声明

charchoose;

menu1();//调用菜单函数

scanf("%c",&choose);

scanf("%c",&choose);

for(;;)

switch(choose)//功能函数选择

{case'1':

tsjinku();break;

case'2':

shanchu();break;

case'3':

chaxunts();break;

case'4':

xianshikucun();break;

case'5':

main1();break;

}

}

 

inttjzs()//统计文本个数函数

{FILE*fp;

inttshuhao=0,txcl=0,n;

chartname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'};

fp=fopen("library.txt","r");//打开文件

for(n=0;!

feof(fp);n++)//逐个读文件

fscanf(fp,"%d%s%s%s%d",&tshuhao,tname,tauthor,tchuban,&txcl);

n--;

fclose(fp);//关闭文件

return(n);//返回个数

}

inttjdzzs()//统计文本个数函数

{FILE*fp;

intzhenghao=0,n;

charmingzi[20]={'\0'},riqi[20]={'\0'},zname[20]={'\0'};

fp=fopen("reader.txt","r");//打开文件

for(n=0;!

feof(fp);n++)//逐个读文件

fscanf(fp,"%d%s%s%s",&zhenghao,&mingzi,&riqi,&zname);

fclose(fp);//关闭文件

return(n);//返回个数

}

 

voidtsjinku()//图书进库函数

{FILE*fp;

intshuhao=0,xcl=0,n=0;

charname[20]={'\0'},author[20]={'\0'},chuban[20]={'\0'};

charhitkey;

system("cls");

if((fp=fopen("library.txt","r"))==NULL)//打开图书馆文件,不存在此文件则新建

{fp=fopen("library.txt","w");

fclose(fp);

}

fp=fopen("library.txt","a");

printf("\n\n\n\n\n\n\t\t\t请按以下格式输入图书信息:

\t\t\t\t\t\t书号书名作者出版社进库量\n请输入:

");//按格式输入图书馆信息

for(;hitkey!

=27;)//循环输入

{if(n!

=0)

printf("请输入:

");

scanf("%d%s%s%s%d",&shuhao,name,author,chuban,&xcl);

fprintf(fp,"%d%s%s%s%d\n",shuhao,name,author,chuban,xcl);

printf("继续输入请按回车,结束输入请按esc\n");

n++;

hitkey=getch();

for(;hitkey!

=13&&hitkey!

=27;)

hitkey=getch();

}

fclose(fp);

printf("\n\n\n\n\n\n\t\t\t保存成功,按任意键返回上一层!

");

getch();

tsgxx();//返回上一层

}

voidshanchu()//删除图书信息函数

{structlibrary*head=NULL;

structlibrary*p,*p1,*p2;

inttshuhao=0,txcl=0,n=0,j,i;

chartname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'},ttname[20]={'\0'};

charhitkey;

FILE*fp;

if((fp=fopen("library.txt","r"))==NULL)//打开文件

{system("cls");

printf("\n\n\n\n\n\n\n\n\n\t\t\t记录文件不存在!

按任意键返回...");

getch();

tsgxx();

}

else

{system("cls");

printf("\n\n\n\n\n\n\n\n\t\t请输入你要删除的书名:

");//输入删除图书书名

scanf("%s",&ttname);

printf("\t\t确认删除请回车,取消请按esc\n");

hitkey=getch();

for(;hitkey!

=13&&hitkey!

=27;)

hitkey=getch();

if(hitkey==27)

tsgxx();

fp=fopen("library.txt","r");

for(j=0;!

feof(fp);)//读文件夹信息,统计个数

{j++;

fscanf(fp,"%d%s%s%s%d",&tshuhao,tname,tauthor,tchuban,&txcl);

}

fclose(fp);

fp=fopen("library.txt","r");

for(i=1;i

{fscanf(fp,"%d%s%s%s%d",&tshuhao,tname,tauthor,tchuban,&txcl);

if(strcmp(ttname,tname))//比较名字,将不同名字的信息复制到链表

{n++;

if(n==1)//建立链表

{p1=p2=(structlibrary*)malloc(LEN);

head=p1;

}

else

{p2->next=p1;

p2=p1;

p1=(structlibrary*)malloc(LEN);//新建链表

}

p1->shuhao=tshuhao;//复制书号

strcpy(p1->name,tname);//复制书名

strcpy(p1->author,tauthor);//复制作者名子

strcpy(p1->chuban,tchuban);//复制出版社

p1->xcl=txcl;//复制个数

}

}

if(n==0)

{head=NULL;

}

else

{

p2->next=p1;

p1->next=NULL;

fclose(fp);

}

}

fp=fopen("library.txt","w");//清空文件

fclose(fp);

fp=fopen("library.txt","a");//追加文件

p=head;

for(;p!

=NULL;)//把链表内容覆盖到文件

{

fprintf(fp,"%d%s%s%s%d\n",p->shuhao,p->name,p->author,p->chuban,p->xcl);

p=p->next;

}

fclose(fp);//关闭文件

system("cls");

printf("\n\n\n\n\n\n\n\n\t\t删除成功\n\t\t按任意键返回上一层\n");

getch();//返回上一层

tsgxx();

}

voidchaxunts()//查询函数

{

FILE*fp;

charchoose;

intttshuhao=0,tshuhao=0,txcl=0,n=0,k=0,i,l;

chartname[20]={'\0'},ttauthor[20]={'\0'},tauthor[20]={'\0'},ttchuban[20]={'\0'},tchuban[20]={'\0'},ttname[20]={'\0'};

if((fp=fopen("library.txt","r"))==NULL)//打开文件

{system("cls");

printf("\n\n\n\n\n\n\n\n\n\t\t\t记录文件不存在!

按任意键返回...");

getch();

tsgxx();

}

l=tjzs();//获得文件个数

menu2();//调用菜单函数

scanf("%c",&choose);scanf("%c",&choose);//选择查询方式

if(choose=='5')

return;

elseif(choose=='1')//书号查询

{system("cls");

printf("请输入书号:

");

scanf("%d",&ttshuhao);

}

else

if(choose=='2')//书名查询

{system("cls");

printf("请输入书名:

");

scanf("%s",ttname);

}

else

if(choose=='3')//作者查询

{system("cls");

printf("请输入作者:

");

scanf("%s",ttauthor);

}

else

if(choose=='4')//出版社查询

{system("cls");

printf("请输入出版社:

");

scanf("%s",ttchuban);

}

system("cls");

for(i=0;i

{fscanf(fp,"%d%s%s%s%d",&tshuhao,tname,tauthor,tchuban,&txcl);//读文件信息

if(ttshuhao==tshuhao||!

strcmp(ttname,tname)||!

strcmp(ttauthor,tauthor)||!

strcmp(ttchuban,tchuban))//输出查询信息

{

if(k==0)

{

printf("\t\t\t\t查询结果:

\n\n");

printf("\t书号书名作者出版社现存量\n");

}

printf("\t%-4d%-8s%-8s%-8s%-4d\n",tshuhao,tname,tauthor,tchuban,txcl);

k++;

}

}

if(k==0)//文件夹为空则输出无记录

{system("cls");

printf("\n\n\n\n\n\n\n\t\t\t\t无符合记录!

\n");

getch();

tsgxx();

}

fclose(fp);

getch();//返回

tsgxx();

}

voidxianshikucun()//现实库存信息

{

FILE*fp;

intshuhao=0,xcl=0,n=0,i=0,j=0;

charname[20]={'\0'},author[20]={'\0'},chuban[20]={'\0'};

if((fp=fopen("library.txt","r"))==NULL)//打开文件夹

{

system("cls");

printf("\n\n\n\n\n\n\n\n\n\t\t\t记录文件不存在!

");

}

n=tjzs();

if(n==0)

{system("cls");

printf("\n\n\n\n\n\n\n\n\n\t\t\t无任何记录!

");

}

fp=fopen("library.txt","r");

system("cls");

printf("********************************************************************************");

printf("\t书号书名作者出版社库存量\n");

printf("********************************************************************************");

for(i=0;i

{

fscanf(fp,"%d%s%s%s%d",&shuhao,name,author,chuban,&xcl);

printf("\t%-4d%-8s%-8s%-8s%-4d\n",shuhao,name,author,chuban,xcl);

}

fclose(fp);

printf("\t\t\t\t按任意键返回\n");

getch();//返回

tsgxx();

}

voidmenu3()//显示借书系统主菜单

{system("cls");

printf("********************************************************************************");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("\t\t\t\t1.借书登记\n\n");

printf("\t\t\t\t2.还书登记\n\n");

printf("\t\t\t\t3.借阅情况查看\n\n");

printf("\t\t\t\t4.返回上一层\n\n");

printf("\t\t\t请按键选择,回车确定\n");

printf("*^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^^_^*");

printf("********************************************************************************");

return;

}

 

voidjieshuxitong()//借书系统函数

{voidjieshu();

voidhuanshu();

voidduzheyilang();//函数声明

charchoose;

menu3();

scanf("%c",&choose);

scanf("%c",&choose);//选择功能

for(;;)

switch(choose)//调用函数

{case'1':

jieshu();break;

case'2':

huanshu();break;

case'3':

duzheyilang();break;

case'4':

main1();break;

}

}

voidjieshu()//借书函数

{

FILE*fp,*fp3;

structlibrary*head=NULL;

structlibrary*p,*p1,*p2;

inttshuhao=0,txcl=0,i,loop,zhenghao=0,n=0,k=0,t=0,flag=0;

chartname[20]={'\0'},tauthor[20]={'\0'},tchuban[20]={'\0'},ttname[20]={'\0'},mingzi[20]={'\0'},riqi[20]={'\0'},zname[20]={'\0'};

charhitkey=0;

system("cls");

{

if((fp=fopen("library.txt","r"))==NULL)//打开图书馆文件

{

system("cls");

printf("\n\n\n\n\n\n\n\n\n\t\t图书馆无库存!

按任意键退出!

");

getch();

exit(0);

}

else

{

{

printf("\n\n\n\n\n\n\t\t\t请输入借阅书名:

\t\t\t\t\t\t\n请输入:

");//输入书名

scanf("%s",zname);

k=tjzs();//统计图书馆文件个数

for(i=0;i

{

fscanf(fp,"%d%s%s%s%d",&tshuhao,tname,tauthor,tchuban,&txcl);

n++;

if(n==1)

{p1=p2=(s

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 艺术创意

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1