版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、VLSI基础_研究总结报告C语言图书馆图书管理程序的研究与设计姓名 沈洪枫 学号 21310105 学院 电气工程学院 专业 电路与系统 目 录一研究内容21.1 工作介绍21.2 作业实现内容2二系统设计22.1 设计分析(采用数据流法):22.2进行系统设计(对主要功能用流程图表示):3第三章 代码设计及测试43.1编写程序代码(主要的程序段和主要的数据结构):43.1.1 main函数43.1.2 book-in函数93.1.3 print函数113.1.4 菜单函数133.1.5 查询函数133.1.6 借阅信息函数173.1.7 书名显示函数193.1.8 图书信息函数193.2系统
2、测试:21第四章 总结28参考文献30第一章 研究内容1.1 工作介绍本文主要是针对一个实用程序图书馆图书管理程序的研究与设计。要建立一个比较完整的图书馆图书管理程序,首先应该考虑该程序的主要功能。该程序首先要能录入新采购的图书信息,并将信息做成一个文件,并且具有一个良好的输入界面;该程序还应该能查询各种图书的基本信息,并具有良好的查询界面;还应将所有图书通过编号进行排序,并将排序好的图书信息输出到文件中;最后,该程序还应该能统计各类图书册数、图书馆的图书总册数。基本概念和原理以及现有的研究成果均已论述在研究计划报告中,此文不再重复。1.2 作业实现内容1.录入新采购的图书信息,做成文件boo
3、k.in,要求有良好的输入界面;2.查询各种图书的基本信息,设计出良好的查询界面;3.按图书编号进行排序,将排好序的图书信息输出到文件 book.out中。4.统计各类图书册数、图书馆的图书总册数。5.统计图书的借阅情况。第二章 系统设计2.1 设计分析(采用数据流法):本题采取一个简单的工程写法,工程中共包含一个main()函数以及七个相应的子程序。(它们分别为book-in函数、print函数、查询函数、图书信息函数、借阅信息函数、书名显示函数以及一个菜单程序)。八部分共同协作来共同完成这个简易的图书管理系统。在main()函数中,定义了一个包含图书的各种信息的结构体;此外,在主函数中还包
4、含了菜单的主要程序段。1到7这七个数字对应七种不同的功能。book-in函数主要完成的工作是:将已经存放在文件中的所有图书信息录入至程序的链表中。在程序运行之前应首先执行该函数,从而再执行其它函数。菜单部分较为简单,仅有一个输出各种不同服务项的功能。通过查询函数,可以通过选择不同的查询方式来查询各种被录入的图书的各种信息。而且查询完后,可以选择继续使用其它种类的服务。当所有的书中不包含此本书时,程序会提醒图书馆中不包含这本书。查询完后,也可以输入5选择进入上一菜单。print()函数主要完成两个任务:一是将图书馆内的所有的图书的最大与最小序号分别输出;二是将所有的图书按照序列排好序,并将结果输
5、出在E盘的一个名为“book.out”的txt文件中。借阅信息函数部分主要用来显示两种信息:一是统计图书馆内的所有图书借出与未被借出的本数;二是输出各种不同类型的图书的借出与未被借出的图书的总本数。书名显示函数最为简单,仅仅输出指针所指向的图书名。2.2进行系统设计(对主要功能用流程图表示):开始运行程序该程序的流程图大体如下:main函数执行book-in查询图书信息借阅信息Print书名显示main函数程序运行结束第三章 代码设计及测试3.1编写程序代码(主要的程序段和主要的数据结构):3.1.1 main函数main():#include#include#include#includes
6、truct book int num; char bookname40; char date_in11; char author40; char type40; char jieyue; struct book *next;#define LEN sizeof(struct book)void caidan();void create(struct book *t);void show(struct book *t);void chaxun(struct book *t);void tushuleixing(struct book *t,char *booktype3);void jieyue
7、leixing(struct book *t,char *booktype3); void print(struct book *t);main() int d; struct book f,*t; char *booktype3; booktype0=教科书; booktype1=教学辅导书; booktype2=杂志; t=&f; printf(本程序通过输入菜单号进行菜单操作,请根据提示及自身需要输入菜单号n); system(pause); system(cls); caidan(); do printf(请输入菜单号n); scanf(%d,&d); while(d7|d0) pri
8、ntf(菜单号不存在,请重新输入); scanf(%d,&d); switch(d) case 1: system(cls); show(t); system(pause); system(cls); caidan(); break; case 2:system(cls); chaxun(t); system(pause); system(cls); caidan(); break; case 3: system(cls); tushuleixing(t,booktype); system(pause); system(cls); caidan(); break; case 4 : syste
9、m(cls); jieyueleixing(t,booktype); system(pause); system(cls); caidan(); break; case 5: system(cls); print(t); printf(打印已完成n); system(pause); system(cls); caidan(); break; case 6: system(cls); printf(请在打开的文本文件中输入新的图书信息,保存后关闭,在修改时,本系统将停止工作,文本文件修改完成后,本系统恢复工作状态n); system(notepad E:图书信息.txt); system(pau
10、se); system(cls); caidan(); break; case 7: system(cls); system(pause); create(t); printf(录入完成); system(pause); system(cls); caidan(); break; while(d!=0); printf(感谢您的使用,请按任意键退出); getch();3.1.2 book-in函数#include#include#include#includestruct book int num; char bookname40; char date_in11; char author40
11、; char type40; char jieyue; struct book *next; #define LEN sizeof(struct book)void create(struct book *t) FILE *fp1,*fp2; struct book *p1,*p2,*head; int i; char *booktype3; booktype0=教科书; booktype1=教学辅导书; booktype2=杂志; head=t; fp1=fopen(E:图书信息.txt,r); fp2=fopen(E:图书信息2.txt,w); fscanf(fp1,%d ,&head-n
12、um); fscanf(fp1,%s ,head-bookname); fscanf(fp1,%s ,head-date_in); fscanf(fp1,%s ,head-author); fscanf(fp1,%s ,head-type); fscanf(fp1,%c,&head-jieyue); p1=p2=head;printf(%d %s %s %s %s %cn,p1-num,p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue) ; for(i=1;inext=p1; fscanf(fp1,n%d ,&p1-num); fscanf(
13、fp1,%s ,p1-bookname); fscanf(fp1,%s ,p1-date_in); fscanf(fp1,%s ,p1-author); fscanf(fp1,%s ,p1-type); fscanf(fp1,%c,&p1-jieyue);printf(%d %s %s %s %s %cn,p1-num,p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue) ; p1-next=NULL; for(i=0;inext) if(strcmp(booktypei,p2-type)=0) fprintf(fp2,%d ,p2-num);
14、 fprintf(fp2,%s ,p2-bookname); fprintf(fp2,%s ,p2-date_in); fprintf(fp2,%s ,p2-author); fprintf(fp2,%s ,p2-type); fprintf(fp2,%cn,p2-jieyue); fclose(fp1); fclose(fp2); 3.1.3 print函数 #include#include#include#includestruct book int num; char bookname40; char date_in11; char author40; char type40; char
15、 jieyue; struct book *next;#define LEN sizeof(struct book)void print(struct book *t) struct book *p1,*p2; int min,max,i; FILE *fp1; fp1=fopen(E:book.out.txt,w); p1=p2=t; max=min=p1-num; i=0; for(p1=t;p1!=NULL;p1=p1-next) if(p1-nummax) max=p1-num; for(p1=t;p1!=NULL;p1=p1-next) if(p1-numnum; printf(%d
16、n,min);printf(%dn,max); for(i=min;inext) if(p2-num=i) fprintf(fp1,%d ,p2-num); fprintf(fp1,%s ,p2-bookname); fprintf(fp1,%s ,p2-date_in); fprintf(fp1,%s ,p2-author); fprintf(fp1,%s ,p2-type); fprintf(fp1,%cn,p2-jieyue); fclose(fp1); 3.1.4 菜单函数#include#include#include#includevoid caidan() printf(1.所有
17、图书n); printf(2.图书查询n); printf(3.图书统计n); printf(4.借阅统计n); printf(5.打印信息n); printf(6.修改信息n); printf(7.录入信息n); printf(0.退出n); 3.1.5 查询函数#include#include#include#includestruct book int num; char bookname40; char date_in11; char author40; char type40; char jieyue; struct book *next;#define LEN sizeof(str
18、uct book)void chaxun(struct book *t) struct book *p1,*head; int xulie; char shuming40; char shijian11; char leixing40; int i; int k=1; head=t; do printf(请输入要查询的方式:n1序列查询 2书名查询 3进书日期查询 4类型查询 5返回上一菜单n); scanf(%d,&i); while(i5|inext!=NULL;p1=p1-next) if ( p1-num=xulie) printf(%d %s %s %s %s %cn,p1-num,
19、p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue); k=0; if(k) printf(没有找到n); break; case 2: printf(请输入书的书名n); scanf(%s,shuming); for(p1=head;p1-next!=NULL;p1=p1-next) if ( strcmp(p1-bookname,shuming)=0) printf(%d %s %s %s %s %cn,p1-num,p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue); k=0; if(k
20、) printf(没有找到n); break; case 3: printf(请输入书的进书日期n); scanf(%s,shijian); for(p1=head;p1-next!=NULL;p1=p1-next) if ( strcmp(p1-date_in,shijian)=0) printf(%d %s %s %s %s %cn,p1-num,p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue); k=0; if(k) printf(没有找到n); break; case 4: printf(请输入书的类型n); scanf(%s,le
21、ixing); for(p1=head;p1-next!=NULL;p1=p1-next) if ( strcmp(p1-type,leixing)=0) printf(%d %s %s %s %s %cn,p1-num,p1-bookname,p1-date_in,p1-author,p1-type,p1-jieyue); k=0; if(k) printf(没有找到n); break; ; k=1; system(pause); system(cls); while(i!=5);3.1.6 借阅信息函数#include#include#include#includestruct book
22、int num; char bookname40; char date_in11; char author40; char type40; char jieyue; struct book *next;#define LEN sizeof(struct book)void jieyueleixing(struct book *t,char *booktype) struct book *p1; int amount1,amount2; int i; amount1=amount2=0; p1=t; for(;p1!=NULL;p1=p1-next) if(p1-jieyue=o) amount
23、1+; else amount2+; printf(借出的有%d本,库存的有%d本n,amount1,amount2); amount1=amount2=0; for(i=0;inext) if(strcmp(p1-type,booktypei)=0)&(p1-jieyue=o) amount1+; if(strcmp(p1-type,booktypei)=0)&(p1-jieyue=i) amount2+; printf(%s类型的书中借出的有%d本,库存的有%d本n,booktypei,amount1,amount2); amount1=amount2=0; 3.1.7 书名显示函数#in
24、clude#include#include#includestruct book int num; char bookname40; char date_in11; char author40; char type40; char jieyue; struct book *next;#define LEN sizeof(struct book)void show(struct book *t) for(;t!=NULL;t=t-next) printf(%sn,t-bookname); 3.1.8 图书信息函数#include#include#include#includestruct boo
25、k int num; char bookname40; char date_in11; char author40; char type40; char jieyue; struct book *next;#define LEN sizeof(struct book)void tushuleixing(struct book *t,char *booktype) struct book *p1; int amount=0; int i;p1=t; for(;p1!=NULL;p1=p1-next) amount+; printf(所有图书共%d本n,amount); amount=0; for
26、(i=0;inext) if(strcmp(p1-type,booktypei)=0) amount+; printf(%s类型的书有%d本n,booktypei,amount); amount=0; 3.2系统测试:1.事先已将所有的图书信息写在一个文件中:2.程序开始运行时,显示整个菜单:3.将所有的图书录入:4.进行图书查询时的界面:(1)书名查询:(2)序列查询:(3)类型查询:(4)进书日期查询:5.所有图书的借阅统计:6.关于所有的图书的统计:7.修改图书的信息时的界面:(程序会自动弹出储存在原文件中的图书信息,即可以在文件中对图书信息进行修改)8.将排序好的图书进行输出(同时显示最大与最小的图书编号
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年南县带编教师招聘考试参考题库及答案解析
- 2026年连江县带编教师招聘笔试模拟试题及答案解析
- 河源市2026-2027学年中考数学最后一模试卷(含答案解析)
- 2026年丹寨县带编教师招聘考试备考试题及答案解析
- 2026年庆安县带编教师招聘考试模拟试题及答案解析
- 2026年新化县带编教师招聘笔试模拟试题及答案解析
- 2026年老年人能力评估师考试理论知识全真模拟试卷及答案(共十三套)
- 2026年和硕县带编教师招聘笔试模拟试题及答案解析
- 2026年桂东县带编教师招聘考试备考题库及答案解析
- 2026年都兰县带编教师招聘考试备考题库及答案解析
- 学校教师荣休仪式退休职工人员欢送会模板
- 小学生班干部竞选课件模板
- DL∕T 651-2017 氢冷发电机氢气湿度技术要求
- 建筑中级职称《给水排水工程》历年考试真题题库(含答案)
- LNG加气站质量管理手册
- 工程量清单及招标控制价编制工作方案
- 2024年全国初中数学联赛试题及答案(修正版)
- 电子元件焊接技术课件
- 土地租用协议
- 记承天寺夜游(王崧舟)
- 动物防疫条件审查场所选址风险评估申请表、评估标准、评估报告
评论
0/150
提交评论