已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本系统结构简单 功能不多 供初学者参考使用 需求分析 我所设计的系统主要包括学生登陆模块和管理员登陆模块 并设置了简单的权 限处理 只有帐号和密码全都正确时方能进入系统 但并未尽善尽美 有些地 方存在漏洞 主要内容及功能如下 学生登录模块 1 图书查询 包括对书名 作者 分类号 即是编号 出版社 出版时间 价 格 总库存量及现库存量的查询 2 图书排序 可对各个图书信息的项目进行从小到大排序 3 浏览全部图书 输出全部图书信息 4 借书系统 每人只可借一本书 5 还书系统 6 修改密码 查看密码是否修改成功时 需要进入查看个人资料 用新密码进入 7 查看个人资料 图书名与分类号初始为 0 意味着尚未借阅任何图书 管理员登陆系统 1 图书查询 2 图书排序 3 浏览全部图书 4 添加图书信息 可逐个添加 也可批量添加 5 删除图书信息 输入时 需要输入图书的分类号 6 修改图书信息 可修改图书名 作者名等相关图书信息 头函数名 include include include void welcome 欢迎用户使用 int denglu1 struct student s int i 学生登陆 int denglu2 管理员登陆 struct book creatbook 创建链表 将文件中的图书信息写入链表 int inputchoice 选择菜单 int inputchoice1 学生选择菜单 int inputchoice2 管理员选择菜单 void pmenu struct book head 学生主功能选择菜单 void menu2 struct book head 管理员主功能选择菜单 struct book addbook struct book head 添加图书信息 int chashu struct book head char m 20 查找分类号是否存在 struct book insert1 struct book head struct book p 增加接点 void printbook struct book head 图书查找 int putchoice 选择查找内容 void chaname1 struct book head 按书名查找 void chaprice struct book head 按价格查找 void chacnum struct book head 按分类号查找 void chazuozhe struct book head 按作者名查询图书信息 void chatime struct book head 按出版时间查找 void chapress struct book head 按出版社查找 void sortbook struct book head 排序选择 void shuming struct book head 按图书名排 void ptime struct book head 按出版时间排序 void price1 struct book head 按图书价格排 void fenleihao struct book head 按图书编号排序 void zuo1 struct book head 按作者名排序 void pre1 struct book head 按出版社排序 struct book shanchubook struct book head 删除图书信息 void fprint struct book head 将新链表写入文件中 void xiugai struct book head 修改图书信息 void printbook1 struct book head 浏览全部图书信息 int chacun struct book head char m 20 查找库存量是否为 0 int jige 求出文件中客户的个数 int xcz struct book head char cnum 20 把库内图书的库存量减一 int xcz1 struct book head char cnum 20 把库内图书的库存量加一 void backbook struct student s int i struct book head 还书函数 void borrowbook struct student s int i struct book head 借书函 数 void xmima struct student s int i 修改密码 void xwj struct student s int i 将修改后的数组写入文件 void oneself struct student s int i 查看个人信息 int jie char cnum 20 int i struct student s char mnum 20 查询 是否借书 int huan int i struct student s char mnum 20 借书查询是否借书 图书信息结构体 struct book char bookname 20 书名 char ename 20 作者 char cnum 20 图书分类号即图书编号 区别其余图书唯一特征 char pubpress 20 出版社 char pubtime 20 出版时间 int price 价格 int zc 现库存 int xc 总库存 struct book next 用链表建立图书信息 int denglu2 管理员登陆系统 FILE fp struct xinxi char mnum 20 管理员登陆账号 char mima 20 管理员登录密码 temp char mnum 20 mima 20 int m n i for i 0 ibookname bookname strcpy p ename ename strcpy p cnum cnum strcpy p pubpress pubpress strcpy p pubtime pubtime p price price p zc zc p xc xc if head NULL head p else tail next p tail p fscanf fp s s s s s d d d bookname ename cnum pubpress pubtime fclose fp tail next NULL return head struct book addbook struct book head 添加图书信息 FILE fp struct book p int size sizeof struct book char bookname 20 书名 char ename 20 作者 char cnum 20 分类号 char pubpress 20 出版社 char pubtime 20 出版时间 int price zc xc 价格 总库存 现库存 int n i printf 如果您已经添加完毕 请将分类号数输入为 0 谢谢合作 n printf 1 少量添加 所添加内容没有存在文件中 n2 批量添加 内容在 文件中存放 n printf 请输入编号 scanf d switch i case 1 printf 请输入图书分类号 scanf s cnum n chashu head cnum if n 1 printf 您输入的分类号已存在 请重新输入 n return head while strcmp cnum 0 0 n chashu head cnum if n 1 printf 图书的分类号已存在 请重新输入 return head p struct book malloc size strcpy p cnum cnum printf 请输入图书名 scanf s bookname strcpy p bookname bookname printf 请输入作者名 scanf s ename strcpy p ename ename printf 请输入出版社 scanf s pubpress strcpy p pubpress pubpress printf 请输入出版时间 scanf s pubtime strcpy p pubtime pubtime printf 请输入价格 scanf d p price price printf 请输入总库存量 scanf d p zc zc printf 请输入现库存量 scanf d p xc xc head insert1 head p cnum printf 请输入图书分类号 scanf s cnum break case 2 if fp fopen book1 txt r NULL printf File do not open exit 0 while feof fp p struct book malloc size fscanf fp s bookname strcpy p bookname bookname fscanf fp s ename strcpy p ename ename fscanf fp s cnum strcpy p cnum cnum n chashu head cnum if n 1 printf 图书的分类号已存在 请重新输入 return head fscanf fp s s d d d pubpress pubtime strcpy p pubpress pubpress strcpy p pubtime pubtime p price price p zc zc p xc xc head insert1 head p cnum break default printf 输入错误 n break return head int chashu struct book head char m 20 查找图书是否存在 int flag 0 struct book p NULL if head NULL return 1 可添加该图书 else p head while p NULL if strcmp p cnum m 0 flag 1 p p next if flag 1 return 1 不可添加该图书 else return 1 struct book insert1 struct book head struct book ptr char cnum 20 增加接点 struct book p p1 p2 p2 head p ptr if head NULL head p1 p1 next NULL else while strcmp p cnum p2 cnum 0 p2 p2 next if strcmp p cnum p2 cnum next p p next p2 else p2 next p p next NULL return head int putchoice 选择查找内容 int mychoice printf n t t t1 按书名查找 n t t t2 按价格查找 n t t t3 按分类 号查找 n t t t4 按作者查找 n t t t5 按时间查找 n t t t6 按出版社查找 n t t t0 退出 n n printf 请输入查询编号 scanf d return mychoice void chaname1 struct book head 按书名查找 struct book p char shuname 20 int flag 0 p head printf 请输入要查找的书名 scanf s shuname printf n printf 查找结果如下 n printf 图书名 t 作者 t 分类号 t 出版社 t 出版时间 t 价格 t 总库存 t 现库存 n while p NULL if strcmp shuname p bookname 0 printf s t s t s t s t s t t d t d t d t p bookname p ename p cnum p pubpress p pubtime p price p zc p xc printf n flag 1 p p next if flag 0 printf 未找到你要找的书 请核实后再输 n void sortbook struct book head 排序选择 int i printf n t t t1 按图书名排序 n t t t2 按出版时间排序 n t t t3 按图书价格排序 n t t t4 按图书分类号排序 n t t t5 按作者名排序 n t t t6 按出版社排序 n t t t0 取消排序操作 n n printf 请输入您选择的选择 scanf d switch i case 0 break case 1 shuming head 按图书名排序 break case 2 ptime head 按出版时间排序 break case 3 price1 head 按出版价格排序 break case 4 fenleihao head 按图书分类号排序 break case 5 zuo1 head 按图书作者排序 break case 6 pre1 head 按出版社排序 default printf 您的输入有误 n break 其中 只给出按价格排序 其余省去 void price1 struct book head 按图书价格排序 struct book a 100 p p1 temp int i k index n 0 char ch p1 head for p head p p p next n for i 0 inext for k 0 k n 1 k index k for i k 1 ipriceprice index i temp a index a index a k a k temp printf 排序成功 n printf 是否显示排序结果 y n n scanf s switch ch case n break case y printf 图书名 t 作者 t 分类号 t 出版社 t 出版时间 t 价格 t 总库 存 t 现库存 n for i 0 ibookname a i ename a i cnum a i pubpress a i pubtime a i price a i zc a i xc break default printf 您的输入有误 n break 删除信息模块 struct book shanchubook struct book head 删除图书信息 char num 20 struct book ptr1 ptr2 p printf 请输入图书分类号 scanf s num p head while p NULL if strcmp p cnum num 0 break p p next if p NULL printf 没有找到该号的图书 n else while head NULL head head next free ptr2 if head NULL return NULL ptr1 head ptr2 head next while ptr2 NULL if strcmp ptr2 cnum num 0 ptr1 next ptr2 next free ptr2 else ptr1 ptr2 ptr2 ptr1 next return head 修改图书信息模块 void xiugai struct book head 修改图书信息 int i char cnum 20 struct book p printf 请输入要修改的图书分类号 scanf s cnum p head while p NULL if strcmp p cnum cnum 0 break p p next if p NULL printf 没有找到该号的图书 n else printf 1 分类号 n2 图书名 n3 作者名 n4 出版社 n5 出版时间 n6 价格 7 修改全部 n0 放弃修改 n case 1 printf 请输入新分类号 scanf s p cnum fprint head printf 修改成功 n break 修改图书信息只给出一部分 无论在添加 删除 还是在修改后 都需要将新 链表写入文件保存起来 因此 就要调用下面的函数 void fprint struct book head 将新链表写入文件中 FILE fp struct book p if fp fopen book txt w NULL printf File open error n exit 0 for p head p NULL p p next fprintf fp s t s t s t s t s t d t d t d n p bookname p ename p cnum p pubpress p pubtime p price p zc p xc fclose fp 而浏览图书信息时就需要浏览函数 void printbook1 struct book head 浏览全部图书信息 struct book p if head NULL printf return printf 全部图书信息如下 n printf 书名 t 作者 t 分类号 t 出版社 t 出版时间 t 价格 t 总库存 t 现库存 n for p head p NULL p p next printf s t s t s t s t s t t d t d t d n p bookname p ename p cnum p pubpress p pubtime p price p zc p xc void pmenu struct book head struct student s int choice m m jige while choice inputchoice1 0 switch choice case 1 if head NULL printf 图书馆管理系统出错 现在无法正常操作 给您带来 的麻烦 我们深表歉意 n break else printbook head 图书查询 break case 2 if head NULL printf 图书馆管理系统出错 现在无法正常操作 给您带来 的麻烦 我们深表歉意 n break else sortbook head 图书排序 break case 3 if head NULL printf 图书馆管理系统出错 现在无法正常操作 给您带来的麻 烦 我们深表歉意 n break else printbook1 head 浏览全部图书信息 break case 4 borrowbook s m head 借书 break case 5 backbook s m head 还书 break case 6 xmima s m 修改密码 break case 7 oneself s m 查看个人资料 break default printf 输入错误 n break 借书与还书模块 void borrowbook struct student s int i struct book head int m n t p flag 0 p1 char mnum 20 mima 20 cnum 20 bookname 20 if i 100 printf 借书人数已满 现不能借书 n else printf 请输入帐号 scanf s mnum printf 请输入密码 scanf s mima for t 0 t i t if strcmp s t mnum mnum 0 scanf s cnum p1 huan i s mnum if p1 1 m chashu head cnum 验证所借图书是否存在 if m
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 机床工厂环保制度
- 星钻科技的奖金制度
- 新苏教版二年级数学下册第七单元《图形的初步认识(三)》全部教案
- 全国小学会考试卷及答案
- 2026农业D打印技术农业产量提高深度调查研究报告
- 2026全球葡萄干贸易格局及中国进出口战略研究报告
- 试论网格系统在概念书籍中的实践应用
- 2026年初级经济师考试综合练习及参考答案详解(培优A卷)
- 2026元宇宙底层技术突破与典型应用场景投资价值研究
- 2026年医学技术职称模拟题库带答案详解(培优A卷)
- 2026年公立医院检验科招聘试题(附答案)
- 2026年自然资源统一确权登记知识测试题
- 2026年二级注册计量师(计量法律法规及综合知识)考试试题及答案
- 钢连廊吊顶及屋顶幕墙安装施工方案
- 2026年北京市顺义区高三一模语文试题
- 2026广东警官学院招聘事业单位人员5人备考题库及答案详解【夺冠】
- 公司业务首单奖励制度
- 房产巡检监督制度
- 2026年中考数学模拟试卷及答案解析(共四套)
- 【《斯特林发动机的发展现状与趋势文献综述》1800字】
- 2025年法医临床考试题库及答案
评论
0/150
提交评论