




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct linkchar 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()
2、;void print(link*head);void hold(link*head);void 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*he
3、ad);int main()int a,b,c,d,e;link *h,*t;L:system("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) sc
4、anf("%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); print(h); break; case 5: hold(h); break; case 6: goto B; break; break; case 3: system("cls"); cxmenu(); while(1) scanf("%d
5、",&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状态n"); printf("n"); printf("%st%
6、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&qu
7、ot;); printf("n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态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
8、 4: t=findauthor(h); if(t=NULL) printf("抱歉,没有找到您要查询的图书!"); else printf("您要查询的图书为:"); printf("n"); printf("n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); printf("n"); printf("%st%st%st%st%st",t->number,t->bookname,t->au
9、thor,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
10、 2: returnbook(h); break; case 3: goto B; break; 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",
11、"r+");if(fp=NULL)printf("没有找到文件,请检查.");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);fscanf(fp,"%s",p-&g
12、t;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); fscanf(fp,"%s",p->sta
13、tus); q->next=p;p->next=NULL;fclose(fp);printf("信息已录入!");return head;void mainmenu()printf("n*n");printf("n 欢迎使用图书管理系统 n");printf("n 1.进入系统 n");printf("n 0.退出系统 n");printf("n*n");printf("n请选择:");void menu1()printf("n*n&
14、quot;);printf("n 1.录入所有图书信息 n");printf("n 2.进入图书管理系统 n");printf("n 3.进入图书查询系统 n");printf("n 4.进入图书借还系统 n");printf("n 5.保存所有图书信息 n");printf("n 6.显示菜单 n");printf("n 7.返回上级菜单 n");printf("n*n");printf("请选择:");void
15、glmenu()printf("n*n"); printf("n 1.显示所有图书信息 n");printf("n 2.添加一本图书信息 n");printf("n 3.修改一本图书信息 n");printf("n 4.删除一本图书信息 n");printf("n 5.保存所有图书信息 n");printf("n 6.返回上级菜单 n");printf("n*n");printf("请选择:");void cxmen
16、u()printf("n*n"); printf("n 1.显示所有图书信息 n");printf("n 2.按编号查询图书 n");printf("n 3.按书名查询图书 n");printf("n 4.按作者查询图书 n");printf("n 5.保存所查询图书信息 n");printf("n 6.返回上级菜单 n");printf("n*n");printf("请选择:");void jhmenu()prin
17、tf("n*n");printf("n 1.借书 n");printf("n 2.还书 n");printf("n 3.返回上级菜单 n");printf("n*n");printf("请选择:");void print(link *head)link *p;p=head;if(p=NULL)printf("文件中没有图书信息n");elseprintf("n");printf("n*n");printf("
18、;n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n");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 h
19、old(link *head)link *p;FILE *fp;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->time);fprintf(f
20、p,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fclose(fp);printf("信息已保存!");void holdcx(link *t)link *p=NULL;FILE *fp;fp=fopen("查询.txt","a+");p=t;fprintf(fp,"查询到的信息为:n");fprintf(fp,"n");fprintf(fp,"n*n");fprintf(
21、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->time);fprintf(fp,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fprintf(fp,"n");fclose
22、(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("请输入图书的
23、书名:");getchar();gets(key);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;retur
24、n t3;link *add(link *head)link *h,*h1;h1=head;h=(link *)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%s
25、tt%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 h;link *sortnumber(link *head)link *p,*q,*temp;temp=(link *)malloc(sizeof(link);if(temp=NULL)printf("申请内存出错!");e
26、xit(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);strcpy(temp->publish,p->publish);strcpy(temp->time,p->
27、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);
28、strcpy(q->number,temp->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
29、 str10;link *h,*t,*p;h=t=p=head;printf("请输入要删除的图书名:");getchar();gets(str);for(;p!=NULL;p->next)k+;if(k>2)t=t->next;if(strcmp(p->bookname,str)=0)&&(k=1)h=p->next;else if(strcmp(p->bookname,str)=0&&k>1)t->next=p->next;else if(strcmp(p->bookname,s
30、tr)=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("修改前图书信息为:");printf("n");printf("n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); printf("n");
31、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出版
32、社tt出版时间tt价格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->author,t->publish,t->time); printf("
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 知识产权教育在学校的普及与推广
- 乡镇工厂租赁合同范本
- 电子书销售平台的市场分析与运营策略
- 现代办公环境下骨科医学影像技术的创新应用
- 科技公司如何通过培训提升员工网络防御能力
- 社区康复支持网络在灾害救援中的应用
- 2025江西南昌市江铜产融社会招聘1人笔试参考题库附带答案详解
- 审车合同范本
- 格式和合同范本
- 2025至2030年中国聚合物瓷砖嵌缝剂数据监测研究报告
- 神奇的光:如何形成彩虹
- 三、胆石症课件
- 学生作业情况登记表模板(可打印)
- 兔子坡(阅读课上课课件)
- 高中数学《立体几何》教材分析及教学建议
- 八年级英语初中英语阅读理解阅读专项练习试卷附答案
- 固定资产清查盘点明细表
- 人教版八年级数学下册课件【全册】
- 物联网管理平台的设计与实现
- 1例妊娠糖尿病的个案护理
- 光伏发电职业病危害预评价方案方案
评论
0/150
提交评论