c语言图书管理系统资料

上传人:微*** 文档编号:89410750 上传时间:2022-05-13 格式:DOCX 页数:15 大小:44.50KB
收藏 版权申诉 举报 下载
c语言图书管理系统资料_第1页
第1页 / 共15页
c语言图书管理系统资料_第2页
第2页 / 共15页
c语言图书管理系统资料_第3页
第3页 / 共15页
资源描述:

《c语言图书管理系统资料》由会员分享,可在线阅读,更多相关《c语言图书管理系统资料(15页珍藏版)》请在装配图网上搜索。

1、#include#include#include typedef struct link char number100;char bookname100;char author100;char publish100;char time100;char status100;float price;struct link *next;link;link *Cbook();void mainmenu();void menu1();void glmenu();void cxmenu();void jhmenu();void print(link*head);void hold(link*head);v

2、oid holdcx(link*t);link *findnumber(link*head);link *findbookname(link*head);link *findauthor(link*head);link *add(link*head);link *sortnumber(link*head);link *delbook(link*head);link *revamp(link*head);link *borrowbook(link*head);link *returnbook(link*head);int main()int a,b,c,d,e;link *h,*t;L:syst

3、em(cls);mainmenu();while(1)scanf(%d,&a);switch(a)case 1:B:system(cls);menu1();while(1)scanf(%d,&b);switch(b)case 1:h=Cbook();break;case 2:system(cls);glmenu();while(1)scanf(%d,&c);switch(c)case 1:print(h);break;case 2:h=add(h);h=sortnumber(h);print(h);break;case 3:revamp(h);break;case 4:h=delbook(h)

4、;print(h);break;case 5:hold(h);break;case 6:goto B;break;break;case 3:system(cls);cxmenu();while(1)scanf(%d,&d);switch(d)case 1: print(h);break;case 2: t=findnumber(h); if(t=NULL) printf( 抱歉 ,没有找到您要查询的图书!);else printf( 您想要查询的为 :); printf(n);printf(n*n);printf(n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 tt 价格 tt

5、 状态 n);printf(n);printf(%st%st%st%st%st,t-number,t-bookname,t-author,t-publish,t-time);printf(tt%.2f,t-price);printf(tt%s,t-status);break;case 3:t=findbookname(h);if(t=NULL)printf( 抱歉 ,没有找到您要查询的图书 !);else printf( 您要查询的图书为 :);printf(n);printf(n*n);出版时间printf(n 编号 tt 书名 tt 作者 tt 出版社 tttt 价格 tt 状态 n);p

6、rintf(n);printf(%st%st%st%st%st,t-number,t-bookname,t-author,t-publish,t-time);printf(tt%.2f,t-price);printf(tt%s,t-status);break;case 4:t=findauthor(h);if(t=NULL)printf( 抱歉 ,没有找到您要查询的图书 !);else printf( 您要查询的图书为 :);printf(n);printf(n*n);出版时间printf(n 编号 tt 书名 tt 作者 tt 出版社 tttt 价格 tt 状态 n);printf(n);p

7、rintf(%st%st%st%st%st,t-number,t-bookname,t-author,t-publish,t-time);printf(tt%.2f,t-price);printf(tt%s,t-status);break;case 5:holdcx(t);break;case 6:goto B;break;break;case 4:system(cls);jhmenu();while(1)scanf(%d,&e);switch(e)case 1:borrowbook(h);break;case 2:returnbook(h);break;case 3:goto B;break

8、;break;case 5:hold(h);break;case 6:system(cls);menu1();break;case 7:goto L;break;break;case 0:printf(ttt 感谢您的使用 ,再见 !);exit(0);return 0;link *Cbook()int n=0;link *p,*q,*head;FILE *fp;fp=fopen( 图书信息.txt,r+);if(fp=NULL)printf( 没有找到文件,请检查 );p=(link *)malloc(sizeof(link);if(p=NULL)printf( 申请内存出错 !n);fsc

9、anf(fp,%s%s%s%s%s,p-number,p-bookname,p-author,p-publish,p-time);fscanf(fp,%f,&p-price);fscanf(fp,%s,p-status);while(feof(fp)=0)n+;if(n=1)head=p;elseq=p;p=(link *)malloc(sizeof(link);if(p=NULL)printf( 申请内存出错!n);fscanf(fp,%s%s%s%s%s,p-number,p-bookname,p-author,p-publish,p-time);fscanf(fp,%f,&p-price

10、);fscanf(fp,%s,p-status);q-next=p;p-next=NULL;fclose(fp);printf( 信息已录入 !);return head; void mainmenu()printf(n*n);n);n);n);printf(n欢迎使用图书管理系统printf(n1.进入系统printf(n0.退出系统printf(n*n);printf(n 请选择 :); void menu1()printf(n1. 录入所有图书信息n);printf(n2.进入图书管理系统n);printf(n3.进入图书查询系统n);printf(n4.进入图书借还系统n);print

11、f(n5.保存所有图书信息n);printf(n6.显示菜单n);printf(n7.返回上级菜单n);printf(n*n);printf(n*n);printf( 请选择 :); void glmenu() printf(n1. 显示所有图书信息n);printf(n2.添加一本图书信息n);printf(n3.修改一本图书信息n);printf(n4.删除一本图书信息n);printf(n5.保存所有图书信息n);printf(n6.返回上级菜单n);printf(n*n);printf(n*n);printf( 请选择 :);void cxmenu()printf(n1. 显示所有图书

12、信息n);printf(n2.按编号查询图书n);printf(n3.按书名查询图书n);printf(n4.按作者查询图书n);printf(n5.保存所查询图书信息n);printf(n6.返回上级菜单n);printf(n*n);printf(n*n);printf( 请选择 :);void jhmenu()printf(nprintf(nprintf(nprintf(n*n);1. 借书n);2.还书n);3.返回上级菜单n);printf(n*n);printf( 请选择 :); void print(link *head) link *p;p=head;if(p=NULL)prin

13、tf( 文件中没有图书信息n); else printf(n);出版时间 tt 价格 tt 状态 n);printf(n*n); printf(n 编号 tt 书名 tt 作者 tt 出版社 tt while(p!=NULL) printf(n);printf(%stt%stt%stt%stt%s,p-number,p-bookname,p-author,p-publish,p-time);printf(tt%.2f,p-price);printf(tt%s,p-status);printf(n); p=p-next;void hold(link *head)link *p;FILE *fp;

14、fp=fopen( 图书信息 .txt,w+);if(fp=NULL) printf( 文件操作出错 !);exit(1);p=head;for(;p!=NULL;p-next) fprintf(fp,n);fprintf(fp,%stt%stt%stt%stt%s,p-number,p-bookname,p-author,p-publish,p-t ime);fprintf(fp,tt%.2f,p-price);fprintf(fp,tt%s,p-status);fclose(fp);printf( 信息已保存!); void holdcx(link *t)link *p=NULL;FILE

15、 *fp;fp=fopen( 查询 .txt,a+);p=t;fprintf(fp, 查询到的信息为 :n);fprintf(fp,n);fprintf(fp,n*n);fprintf(fp,n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 tt 价格 tt 状态 n);fprintf(fp,n);fprintf(fp,%stt%stt%stt%stt%s,p-number,p-bookname,p-author,p-publish,p-t ime);fprintf(fp,tt%.2f,p-price);fprintf(fp,tt%s,p-status);fprintf(fp,n

16、);fclose(fp);printf( 信息已保存!);link *findnumber(link *head)char key100;link *h,*t1=NULL;printf( 请输入图书的编号:);getchar();gets(key);for(h=head;h!=NULL;h=h-next)if(strcmp(key,h-number)=0)t1=h;break;return t1; link *findbookname(link *head)char key100;link *h,*t2=NULL;printf( 请输入图书的书名 :);getchar();gets(key);

17、for(h=head;h!=NULL;h=h-next)if(strcmp(key,h-bookname)=0)t2=h;break;return t2; link *findauthor(link *head)char key100;link *h,*t3=NULL;printf( 请输入作者姓名 :);getchar();gets(key);for(h=head;h!=NULL;h=h-next)if(strcmp(key,h-author)=0)t3=h;break;return t3; link *add(link *head) link *h,*h1;h1=head;h=(link

18、*)malloc(sizeof(link);if(h=NULL)printf( 申请内存出错 !);exit(1);printf( 请输入添加图书的信息 :);printf(n);printf(n*n);printf(n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 tt 价格 tt 状态 n);printf(n);scanf(%stt%stt%stt%stt%s,h-number,h-bookname,h-author,h-publish,h-time );scanf(tt%f,&h-price); scanf(tt%s,h-status); h-next=h1;return

19、h;link *sortnumber(link *head) link *p,*q,*temp;temp=(link *)malloc(sizeof(link);if(temp=NULL)printf( 申请内存出错 !);exit(1);for(p=head;p!=NULL;p=p-next)for(q=p-next;q!=NULL;q=q-next)if(strcmp(p-number,q-number)0) strcpy(temp-number,p-number); strcpy(temp-bookname,p-bookname); strcpy(temp-author,p-author

20、);strcpy(temp-publish,p-publish);strcpy(temp-time,p-time);temp-price=p-price;strcpy(temp-status,p-status);strcpy(p-number,q-number); strcpy(p-bookname,q-bookname); strcpy(p-author,q-author);strcpy(p-publish,q-publish);strcpy(p-time,q-time);p-price=q-price;strcpy(p-status,q-status);strcpy(q-number,te

21、mp-number); strcpy(q-bookname,temp-bookname); strcpy(q-author,temp-author);strcpy(q-publish,temp-publish);strcpy(q-time,temp-time);q-price=temp-price;strcpy(q-status,temp-status);return head;link *delbook(link *head) int k=0;char str10;link *h,*t,*p;h=t=p=head;printf( 请输入要删除的图书名 :);getchar();gets(st

22、r);for(;p!=NULL;p-next)k+;if(k2)t=t-next;if(strcmp(p-bookname,str)=0)&(k=1)h=p-next;else if(strcmp(p-bookname,str)=0&k1)t-next=p-next;else if(strcmp(p-bookname,str)=0&p-next=NULL) t=NULL;return h; link *revamp(link *head)link *h,*t;h=head;t=findbookname(h);if(t=NULL)printf( 没有找到 );elseprintf( 修改前图书信

23、息为:);printf(n);printf(n*n);printf(n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 tt 价格 tt 状态 n); printf(n);printf(%stt%stt%stt%stt%s,t-number,t-bookname,t-author,t-publish,t-time);printf(tt%.2f,t-price);printf(tt%s,t-status);printf(n);printf( 请输入这本书(书名除外)所有信息:n);printf(n*n);printf(n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 t

24、t 价格 tt 状态 n); printf(n);scanf(%stt%stt%stt%stt%s,t-number,t-bookname,t-author,t-publish,t-time);scanf(tt%2f,&t-price);scanf(tt%s,t-status);printf( 修改后图书信息为:n);printf(n);printf(n*n);printf(n 编号 tt 书名 tt 作者 tt 出版社 tt 出版时间 tt 价格 tt 状态 n); printf(n);printf(%stt%stt%stt%stt%s,t-number,t-bookname,t-autho

25、r,t-publish,t-time);printf(tt%.2f,t-price);printf(tt%s,t-status);printf(n);return head;link *borrowbook(link *head)link *h,*p;char ch,ch1100=在库,ch2100=不在库;h=head;printf(n*n);printf( 欢迎使用借书系统!n);p=findbookname(h);if(p=NULL)printf( 借书失败,书库中没有这本书!);else if(strcmp(p-status,ch2)=0)printf( 借书失败 ,书库中没有这本书

26、!);elseprintf( 确认借出 ?Y/N:);scanf(%c,&ch);getchar();if(ch=Y|ch=y)strcpy(p-status,ch2);printf( 借书成功,请返回上级菜单保存信息!);if(ch=N|ch=n)printf( 你没有借任何书 !);return head;link *returnbook(link *head)link *h,*p;char ch,ch1100=在库,ch2100=不在库 h=head;*n);printf(nprintf( 欢迎使用还书系统!n);p=findbookname(h);if(p=NULL)printf( 还书失败,这不是本库的书 !);elseprintf( 确认还书 ?Y/N:);scanf(%c,&ch);getchar();if(ch=Y|ch=y)strcpy(p-status,ch1);printf( 还书成功,请返回上级菜单保存信息!);if(ch=N|ch=n)printf( 你没有还书 !);return head;

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!