已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
.struct book /*图书信息*/int num; /*书号*/char name10; /*书名*/char where10; /*所在书库*/char author15; /*作者*/char pub20; /*出版社*/int count; /*数量*/struct book *next;/*输出模块*/void print(struct book *p0)struct book *p;p=p0-next;printf(nntt图书信息表);printf(nn图书编号-图书名称-所在书库-作者-出版社-数量n);while(p!=NULL)printf(PT);p=p-next;getch();/*输入模块*/struct book *creat() struct book *head,*p1,*p2;int i=0;head=p2=(struct book *)malloc(N);head-next=NULL;printf(nntt录入图书信息);printf(nt-);while(1) p1=(struct book *)malloc(N);printf(n 请输入图书编号(书号为0结束): );scanf(%d,&p1-num);if(p1-num!=0)printf(nn书名 所在书库 作者 出版社 图书数量n);scanf(%s%s%s%s%d,p1-name,p1-where,p1-author,p1-pub,&p1-count);p2-next=p1;p2=p1;i+;else break;p2-next=NULL;free(p1);printf(ntt-);printf(ntt %d 种书录入完毕,i);getch();return head;/*查找模块*/void find(struct book *p0)char name10;int flag=1;struct book *p;p=p0-next;printf(请输入要查找的书名:n);scanf(%s,name);for(p=p0;p;p=p-next)if(strcmp(p-name,name)=0) printf(nn图书编号-图书名称-所在书库-作者-出版社-数量n);printf(PT);flag=0;break;if(flag) printf(n 暂无此图书信息n);getch();/*删除模块*/void del(struct book *p0)char name10;int flag=1;struct book *p;p=p0;printf(请输入要删除的书名:n);scanf(%s,name);while(p!=NULL)if(strcmp(p-name,name)=0)p0-next=p-next; /*后续节点连接到前驱节点之后*/free(p);printf(t该书资料已删除.);flag=0;break;p0=p;p=p-next;if(flag) printf(nt无此图书信息。);getch();/*增加模块*/void insert(struct book *p0)struct book *p;p=(struct book *)malloc(N);while(1)printf(n 请输入要增加的图书编号(书号为0 退出): );scanf(%d,&p-num);if(p-num!=0)if(p0-next!=NULL&p0-next-num=p-num) /*找到重号*/p=p-next;free(p);printf(t该书已存在);else printf(nn书名 所在书库 作者 出版社 图书数量n);scanf(%s%s%s%s%d,p-name,p-where,p-author,p-pub,&p-count);p-next=p0-next;p0-next=p;printf(t已成功插入.);else break;getch();/*修改模块*/void modify(struct book *p0)char name10;int flag=1;int choice;struct book *p;p=p0-next;printf(请输入要修改的书名:n);scanf(%s,name);while(p!=NULL&flag=1)if(strcmp(p-name,name)=0)printf(nt请选择要修改的项:);printf(nt 1.修改图书编号n);printf(nt 2.修改图书所在书库n);printf(nt 3.修改图书作者n);printf(nt 4.修改图书出版社n);printf(nt 5.修改图书库存量n);scanf(%d,&choice);switch(choice)case 1: printf(n 请输入新的图书编号:);scanf(%d,p-num); break;case 2: printf(n 请输入新的图书书库:);scanf(%s,p-where); break;case 3: printf(n 请输入新的图书作者:);scanf(%s,p-author); break;case 4: printf(n 请输入新的图书出版社:);scanf(%s,p-pub); break;case 5: printf(n 请输入新的图书库存量:);scanf(%d,p-count); break;printf(nt该项已成功修改。nt 新的图书信息:);printf(nn图书编号-图书名称-所在书库-作者-出版社-数量n);printf(PT);flag=0; p0=p;p=p0-next;if(flag) printf(nt暂无此图书信息。);getch();/*读文件*/struct book *read_file() int i=0;struct book *p,*p1,*head=NULL;FILE *fp;if(fp=fopen(library.txt,rb)=NULL)printf(nnnnn t*库文件不存在,请创建!*);getch();return NULL;head=(struct book *)malloc(N);p1=head;head-next=NULL;printf(n 已有图书信息:);printf(nn图书编号-图书名称-所在书库-作者-出版社-数量n);while(!feof(fp)p=(struct book *)malloc(N); /*开辟空间以存放的取得信息*/while(fscanf(fp,%d%s%s%s%s%d,&p-num,p-name,p-where,p-author,p-pub,&p-count)!=EOF)printf(PT);i+;p1-next=p;p1=p;p1-next=NULL;fclose(fp);printf(n 共种%d 图书信息,i);printf(nnn 文件中的信息以正确读出。按任意键进入主菜单。);getch();return (head); /*保存文件*/void save(struct book *head) FILE *fp;struct book *p;fp=fopen(library.txt,wb); /*以只写方式打开二进制文件*/if(fp=NULL) /*打开文件失败*/printf(n=打开文件失败!n);getch();return ;elsefor(p=head-next;p!=NULL;p=p-next)fprintf(fp,%d %s %s %s %s %dn,p-num,p-name,p-where,p-author,p-pub,p-count);fclose(fp);printf(nt保存文件成功!n);void main()struct book *head=NULL;int choice=1;head=read_file();if(head=NULL)printf(ntt*);getch();head=creat();dosystem(cls);printf(tt-Welcome-n);printf(nnt欢迎您,图书管理员.n);printf(nnnnn);printf(nt 请选择:);printf(nt 1.查询图书信息n);printf(nt 2.修改图书信息n);printf(nt 3.增加图书信息n);printf(nt 4.删除图书信息n);printf(nt 5.显示所有图书信息n);printf(nt 0.退出系统n);scanf(%d,&choice);switch(choice)case 1: find(head); brea
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025西部证券投资业务岗位招聘备考题库含答案详解(培优b卷)
- 跨境电商对边境城市经济高质量发展的促进作用
- 2025海南昌江黎族自治县发展控股集团有限公司招聘企业高级管理人员1人备考题库附答案详解(突破训练)
- 商场灭火器配置与管理方案
- 2025年杭州市疾控面试题及答案
- 再生砂混凝土性能研究与应用探索
- 2025北京振远护卫有限公司招聘备考题库含答案详解(达标题)
- 2025年国家电投集团河南公司招聘8人备考题库及参考答案详解1套
- 深基坑支护技术在建筑工程管理中的应用优化
- 最好的健康测试题及答案
- 大学生职业生涯规划与就业创业指导教学教案
- 杜城村道路施工方案
- 2025及未来5年渗水砖项目投资价值分析报告
- 2024南京交通职业技术学院辅导员招聘笔试真题
- 工业机器人离线编程与仿真【项目五 】教案
- 【2025年】宪法知识竞赛题库及答案
- 1.2复杂多变的关系教案 2024-2025学年统编版道德与法治九年级下册
- 风光摄影讲座课件
- 门诊部科主任述职报告
- DGTJ08-10-2022 城镇天然气管道工程技术标准
- 2025年及未来5年中国妇科抗炎药物市场规模预测及投资战略咨询报告
评论
0/150
提交评论