




已阅读5页,还剩34页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
目录一、题目描述:2二、题目要求:2三、需求分析:3四、总体设计:4五、实现过程与解决的主要问题81、实现过程:82、解决的主要问题问题:93、测试过程及结果:10六、特色及有待改进的方面:18七、自我体会与评价:19八、参考文献:19九、源代码:19一、题目描述:设计一个图书登记管理程序。二、题目要求:1、图书信息应该包括编号,书名,出版社和价格等;2、按照分析,设计,编码,调试和测试的软件开发过程完成这个应用程序;3、为各项操作功能设计一个菜单,应用程序运行后,先显示这个菜单,然后用户通过菜单项选择希望进行的操作项目。4进入每个操作后,根据应用程序的提示信息,从键盘输入相应的信息。要求用户输入数据时,要给出清晰,明确地提示信息,包括输入的数据内容,格式及结束方式等。三、需求分析:该程序具有以下功能:1、应用程序运行后,在屏幕上显示一个菜单。用户可以根据需求,选定相应的操作项目。进入每个操作后,根据应用程序的提示信息,从键盘输入相应的信息。2、录入图书信息。3、给定图书编号,显示某本图书的信息;4、给定某个关键字,显示所有书名中包含该关键字的图书信息;5、给定出版社,显示该出版社的所有图书信息;6、删除某本图书的信息;7、提供一些统计各类信息的功能。扩展功能:将所有图书信息存储在一个文件中,并实现文件读写的操作。四、总体设计:文件及函数组成 :图书登记管理系统Main(主控函数)Menuselect(菜单选择函数) Case2Number(编号)Case6Statistic(统计)Case5Del(删除)Case4Publish(出版社)Case1Readin(录入)Case7Exit(退出)Case3Keyword(关键字)运用技术:1、收集图书书名,出版社(字符型数组),价格(实型)图书编号(整型);2、调用printf打印目录;3、用switch,使用户选择操作项目,共有7case;4、Case 1 录入某本图书的信息,调用printf打印出“书名 出版社 价格 编号” case2给定图书编号,显示某本图书的信息; case3给定某个关键字,显示所有书名中包含该关键字的图书信息;case4给定出版社,显示该出版社的所有图书信息; case5删除某本图书的信息;case6提供一些统计各类信息的功能;case7退出。源文件函数名或其他成分功能模块Record.cmainmenu-select总控函数菜单选择Inputs.creadin录入图书信息Number给定图书编号,显示某本图书的信息keyword.ckeyword给定关键字显示所有书名中含该关键字的图书信息Publish.cpublisher给定出版社,显示该出版社的所有图书信息;Delete.cdelete删除某本图书的信息Statistic.cstatistic统计功能Record.h库函数及函数声明结构声明引用库函数及其他函数结构类型定义 头文件应包含的内容 声明函数原型 包含文件 自定义宏 数据结构 菜单选择函数menu_select 函数原型:void menu_select() 功能:接收用户选择的命令代码 参数:无参数 工作方式:返回命令代码的整数值 要求:只允许选择规定键,如果输入不符合要求,则提醒用户重新输入录入信息函数 -函数原型:void readin()-功能:录入图书信息-参数:无参数-要求:正确输入图书信息编号函数-函数原型:void number()-功能:给定图书编号,显示某本图书的信息-参数:无参数 -要求:正确输入要查的书的编号关键字函数-函数原型:void keyword()-功能:给定关键字显示所有书名中含该关键字的图书信息-参数:无参数-要求:正确输入关键字 出版社函数-函数原型:void publish()-功能:给定出版社,显示该出版社的所有图书信息-参数:无参数-要求:正确输入出版社名字删除函数-函数原型:void del()-功能:删除图书信息-参数:无参数-要求:输入要删除图书的编号统计函数 -函数原型:void statistic()-功能:统计功能-参数:无参数-要求:正确输入出版社名称 退出函数-函数原型:exit(int)-功能:退出程序-参数:整型数据 五、实现过程与解决的主要问题1、实现过程:一、 首先要对整个程序有个全局的理解,清楚知道程序要实现的功能。二、 先进行需求分析,再编写。三、 上机编写代码,定义函数及各种声明,分模块编写函数。1、.record.c中含主函数和menuselect函数;2、 input.c中含录入信息函数,应用了结构体数组,将图书多种信息定义在一起,便于操作管理;3、number.c中含编号函数,应用2个循环(if和for),1次打开和关闭文件完成功能;4、keyword.c 中含关键字函数,应用1个标签, 1次打开和关闭文件,1个循环嵌套和1个if循环完成功能;5、Publish.c含出版社函数,应用1个标签,1次打开和关闭文件,1个循环嵌套和2个if循环完成功能;6、Delete.c含删除函数,应用2次打开和关闭文件,1个循环嵌套和1个if循环完成功能,1个for循环完成功能;7、Statistic.c含统计函数,应用1个标签, 1次打开和关闭文件,1个循环嵌套和2个if循环完成功能;四、先单独进行编译,没有错误后再建工程,一起进行连接和运行。发现错误后及时进行修改和测试,能够运行后,再次进行检查和修改,使程序趋近于完善。2、解决的主要问题问题:1. 由于疏忽而造成的中英文标点错误,由于不认真忘记加分号,源代码输入错误;2. 实现功能的算法有错误;3.由于知识掌握不牢固而产生的技术错误。3、测试过程及结果:菜单:录入图书信息:给定图书编号,显示某本图书的信息:给定关键字显示所有书名中含该关键字的图书信息:给定出版社,显示该出版社的所有图书信息:删除某本图书的信息:统计功能:结束程序:六、特色及有待改进的方面:特色:1、各个功能结束之后自动清屏,便于使用者使用; 2、操作简单、明了; 3、每个功能完成后能返回主菜单继续进行其他操作。有待改进:1、关键字函数中关键字只是书名; 2、统计函数只有一个功能。七、自我体会与评价:体会:这此实训,我学到了许多知识。我明白了编程并不是一开始便编写,在编写程序之前还要做许多工作,包括理解题目、进行需求分析、函数构想、功能构想。编程时须认真严谨,测试的过程需要耐心和毅力。遇到困难时,要先自己思考,实在不懂就向他人求助或上网查询,但一定要弄明白,掌握这个知识。评价:对自己的实训成果在一定程度上比较满意。源代码独立完成、测试时向学长学姐请教过,明白了错在何处。不足就是缺乏耐心,不太认真,爱犯细节错误。八、参考文献: 标准C语言基础教程C语言程序设计实验实训教程九、源代码:Record.h#ifndef _H_RECORD_H#define _H_RECORD_H#include#include#include#include#include#include#define n 2#define MAX 20struct Book int nums;char name20;char author30; char publisher30; float price;extern struct Book books200;void menuselect();/function prototypevoid readin();/function prototypevoid numb();/function prototypevoid publish();/function prototypevoid keyword();/function prototypevoid del();/function prototypevoid statistic();/function prototype#endifRecord.c#includerecord.hstruct Book books20;int main()menuselect(); /the function is called herereturn 0;void menuselect() /function header int opselect;menu:Sleep(1000);/sleep one secondssystem(cls);/clean the screanprintf(-图书登记管理系统-nn); printf(-目录-nnn);printf(1、录入图书信息n);printf(2、给编号,显示图书信息n);printf(3、给关键字,显示该书的图书信息n);printf(4、给定出版社,显示该出版社出版的所有图书n);printf(5、给编号,删除图书信息n);printf(6、统计n);printf(7、退出nn); printf(Enter a select code: );scanf(%d,&opselect); if(opselect7|opselect1) printf(输入不符合要求,请重新输入n); goto menu; else switch(opselect) case 1: readin( );/the function is called here break; case 2: numb();/the function is called here break; case 3: keyword();/the function is called here break; case 4: publish();/the function is called here break; case 5: del();/the function is called here break; case 6: statistic();/the function is called here break; case 7: exit(1);/end the program break; Inputs.c#include record.hvoid readin() /function header int i,sum;FILE *infile;infile=fopen(book.txt,a); /open the fileif(infile = NULL) printf(Dont open the file!n);printf(Please enter the sum number of the input books: );scanf(%d,&sum);for(i=0;isum;i+) printf(Number: );scanf(%d,&booksi.nums);printf(nName: );scanf(%s,);printf(Author: );scanf(%s,booksi.author );printf(Publisher: );scanf(%s,booksi.publisher);printf(Price: );scanf(%f,&booksi.price);fprintf(infile,%d%s%s%s%fn,booksi.nums,,booksi.author,booksi.publisher, . booksi.price,booksi.store); fclose(infile); /close the filemenuselect();/the function is calling here,return to the menuNumber.c#includerecord.hvoid numb() /function header int count,i=0; FILE*infile; infile=fopen(book.txt,r); /open the file if(infile=NULL) printf(nFail to open the file.n); exit(1); else printf(nThe file is successfully opened.n); printf(Please enter the order of the book: ); scanf(%d,&count); count-; for(i=0;i20;i+) fscanf(infile,%d,&booksi.nums); fscanf(infile,%s,);fscanf(infile,%s,booksi.author); fscanf(infile,%s,booksi.publisher); fscanf(infile,%f,&booksi.price); printf(Number: %dn,bookscount.nums); printf(Name: %sn,);printf(Author: %sn,bookscount.author); printf(Publisher: %sn,bookscount.publisher); printf(Price: %fn,bookscount.price); Sleep(3000);/sleep three seconds fclose(infile); /close the file menuselect();/the function is calling here,return to the menuKeyword.c#includerecord.hvoid keyword() /function header char key30; int i=0; int position=0; int Corr=0;/make a tagFILE *infile;infile=fopen(book.txt,r); /open the fileif(infile=NULL) printf(nFail to open the file.n); exit(1); else printf(nThe file is successfully open.); getchar(); printf(nPlease enter the book name which you want to search: ); gets(key); for(i=0;i10;i+) fscanf(infile,%d%s%s%s%fn,&booksi.nums,,booksi.author,booksi.publisher, . &booksi.price); if(strcmp(key,)=0) position = i; Corr=1; if(Corr=1) printf(Number: %dn,booksposition.nums); printf(Name: %sn,); printf(Author: %sn,booksposition.author); printf(Publisher: %sn,booksposition.publisher); printf(Price: %fn,booksposition.price); Sleep(3000); /sleep three seconds else printf(Dont Found!n); fclose(infile); /close the filemenuselect();/the function is calling here,return to the menuPublish.c#includerecord.hvoid publish() /function header char print30; int i=0,j=0; int positionMAX; int Corr=0;/make a tagint maxj; FILE *infile;infile=fopen(book.txt,r); /open the fileif(infile=NULL) printf(nFail to open the file.n); exit(1); else printf(nThe file is successfully open.); getchar(); printf(nPlease enter the publish which you want to search: ); gets(print); for(i=0;i10;i+) fscanf(infile,%d%s%s%s%fn,&booksi.nums,,booksi.author,booksi.publisher, . &booksi.price); if(strcmp(print,booksi.publisher)=0) positionj = i; Corr=1; j+; maxj=j; if(Corr=1) j=0; for(i=0;imaxj;i+) printf(Number: %dn,bookspositionj.nums); printf(Name: %sn,); printf(Authorr: %sn,bookspositionj.author); printf(Publisher: %sn,bookspositionj.publisher); printf(Price: %fn,bookspositionj.price); printf(n-n); Sleep(1000);/sleep one seconds else printf(Dont Found!n); fclose(infile); /close the fileSleep(1000);/sleep one secondssystem(pause);menuselect();/the function is calling here,return to the menuDelete.c#includerecord.hvoid del() /function header FILE*infile; FILE*outfile; int i; int j; int booksCount;/ Count the number of books that has already saved into memory. int delS=0;infile=fopen(book.txt,r); /open the fileif(infile=NULL) printf(nFail to open the file.n);exit(1);elseprintf(nThe file is successfully opened.n); printf(Please enter the number of the book which you want to deleted: );scanf(%d,&j);printf(The number of the book you want to delete is %dn,j);booksCount = 0; / Initializaiton. while(fscanf(infile,%d%s%s%s%fn, &booksbooksCount.nums,booksbooksC,booksbooksCount.author ,booksbooksCount.publisher,&booksbooksCount.price) != EOF) / Scan the file until meet EOF, i.e., the End Of File.if(booksbooksCount.nums = j) / booksCount remain the same.else booksCount+; fclose(infile);outfile = fopen(book.txt,w);printf(%dn!,booksCount+1);for(i=0;ibooksCount;i+) fprintf(outfile,%d%s%s%s%fn,,booksi.authorbooksi.publisher,booksi.price);fclose(outfile); /close the fileSleep(3000);/sleep three secondsmenuselect();/the function is ca
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 施工现场安全目标与保障措施方案
- 幼儿园小班教师周工作计划模板
- 甲供材料管理方案及流程规范
- 建设工程安全管理职责与流程
- 漯河小区收费管理办法
- 网上政务服务管理办法
- 矿坑回收动态管理办法
- 物业服务合同范本及管理规范解析
- 潍坊健身设施管理办法
- 建筑电焊工安全操作规程及注意事项
- 2025年留置辅警考试题库及答案
- 2025年国企应聘测试题及答案
- 《创新创业基础 第2版》 课件 第1章 认识创业
- 血液净化中心静脉导管护理指南
- 高压蒸汽灭菌原理
- 小儿过敏性紫癜护理常规
- 手术标识培训课件
- 超声下椎管麻醉技术应用
- 2025至2030年中国硫酸钙晶须行业市场竞争现状及投资前景研判报告
- 电厂网格化管理制度
- 电梯安全总监职责、安全员守则
评论
0/150
提交评论