版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、中国地质大学(武汉)学 院:专 业:姓 名: 学 号:.指导老师:_20目录1 .题目要求 32 .需求分析 33 .总体设计 44 .详细设计44.1 主函数 44.2 各功能模块设计 54.2.1 信息输入模块54.2.2 信息查找模块64.2.3 新物资入库模块84.2.4 领料模块84.2.5 打印功能模块84.2.6 采用文件来存储数据信息 95 .上机操作 106 .总结 13附录 14物资管理系统1. 题目要求请设计一个物资管理系统,要求主程序中应提供文字交互菜单界面,要求包含以下几个功能模块:1. 信息输入模块input():建立物资管理数据总文件,完成对物资原库存信息的录入,
2、并存放到指定文件中(pro.dat)2. 信息查找模块search():采用如下方式进行查找,若找到,则输出该物资的相关信息;没有则给出提示信息。(1 )按产品名称查询(2)进货日期查询并统计。(3 )按产品名称和规格查询并统计。3. . 新物资入库模块insert():在原数据文件中插入新物资的信息。4. 领料*II块lend():查找所领取物资的信息,满足领料的要求,请登记领取物资名称,日期,数量(领料后修改)5. .打印功能模块printf ()(1)打印领料单(2 )打印物资库存清单。【提示】建立如下结构体:struct dateint year ;int month ; int da
3、y;struct productchar p_name20;物资名称long int p_num7;物资编号char size4;物资规格struct date in date;进货日期long int max_s;最大库存量 long int min_s;最小库存量 long int real_s;实际库存量struct product*next; 结点指针 Struct l_prochar p_name 20;物资名称struct date l_date;领料日期 long int total ;领料数量 struct l_pro*next;结点指针;2. 需求分析根据题目要求,由于物资信
4、息是存放在文件中,所以提供文件的输入, 输出等操作在程序中需要浏览物资的需要浏览物资信息,应提供显示,查找等操作;另外还应提供键盘选择菜单实现功能选择。三.总统设计根据上面的分析及题目要求可以分为以下六个模块。图(1)系统模块图四. 详细设计(1) 主函数:主函数一般是设计简洁,只提供输入,处理和输出部分的函数调用。其中各功能模块用菜单方式选择。其中流程图如图(2)menu()/* 主函数 */int n,w1; doputs(ttt*menu*nn);puts(ttt l.enter new datann);/* 输入数据 */puts(ttt 2.search menunn);/* 查找信
5、息*/puts(ttt 3.insert new datann);/* 插入新数据 */puts(ttt4.lend datann);/* 领料数据 */puts(ttt5.print datann);/* 打印*/puts(ttt 6.exit);/* 退出 */ printf(Please choose the number 1-6: bb);puts(nttt*n);scanf(%d,&n);if(n6)w1=1;getchar();else w1=0;while(w1=1);switch(n)case 1:enter();break;case 2:search();break;case
6、 3:insert();break;case 4:lend();break;case 5:print();break;case 6:exit(0);main()menu();(2)各功能模块设计图(2)主函数流程图1 .信息输入模块:主要是为了输入商品类型,名称,数量,型号,日期,最大,最小,真实库存量,并存放在指定的文件(pro.dat)中。enter()/*信息输入模块*/0nt i,n;开始printf(nHow many products do you want to input(0-%d)?:,N-1);scanf(%d,&n);printf(nEnter data now!nn);
7、输入用 户 要输入的。二卜计+)学生记飞的个数nprintf(Please input the %dth products data:n,i+1);input(i);if(i!=0)save(n);printf_back();input(int i)printf(nname(1-20letter):);scanf(%s,&proi.p_name); printf(nnumber(1-7letter):); scanf(%d,&proi.p_num); printf(nsize(1-4letter):); scanf(%s,&proi.size); printf(ndate(*.*.*):);i
8、从0到n1调用输入函数input (i)图(3)信息输入模块scanf(%d.%d.%d,&proi.in_date.year,&proi.in_date.month,&proi.in_date.day); printf(min_s real_s max_s:);scanf(%d %d %d,&proi.min_s,&proi.real_s,&proi.max_s);printf_data(int i)printf(nnametnumttsizetdatettmin real maxn);printf(%st%dtt%st%d.%d.%dt%d-%d-%d,proi.p_name,proi.p
9、_num,proi.size,proi.in_d ate.year,proi.in_date.month,proi.in_date.day,proi.min_s,proi.real_s,proi.max_s); printf_back()printf(nnSuccessful!nttThank you!n);getch();menu();2 .查询模块search()/*信息查找模块*/ int n,w2;doputs(ttt*search menu*nn);puts(ttt1.search by name);puts(ttt2.search by data);puts(ttt3.search
10、 by name and size);puts(ttt4.exit);puts(nttt*n);printf(Choose the number to search 1-4: bb);scanf(%d,&n);if(n4)w2=1;getchar();else w2=0;while(w2=1);switch(n)case 1:search_by_name();break;case 2:search_by_date();break;search_by_name()/*按名称查找*/显示找到的记录提示没有找到int j,n,m=0;char a20;n=load();printf(nInput t
11、he products namenname:); scanf(%s,a);结束for(j=0;jn;j+)图(4)查找模块if(strcmp(a,proj.p_name)=0)m+;printf_data(j);printf(nThis is the %dth product you have searched!,m);getch();menu();struct s_date/*按日期查找 */int year;int month;int day;s;search_by_date()int j,n,m=0;n=load();printf(nInput the date(*.*.*)ndate:
12、);scanf(%d.%d.%d,&s.year,&s.month,&s.day);for(j=0;jn;j+)if(s.year=proj.in_date.year)&(s.month=proj.in_date.month)&(s.day=proj.in_dat e.day)m+;printf_data(j);printf(nThis is the %dth product you have searched!,m);getch();menu();search_by_nameandsize()/* 按名称和规格查找 */int j,n,m=0;char a20,b4;n=load();pri
13、ntf(nInput the products namenname:);scanf(%s,a);printf(nInput the products sizensize:);scanf(%s,b);for(j=0;jn;j+)if(strcmp(a,proj.p_name)=0)&(strcmp(b,proj.size)=0)m+;printf_data(j);printf(nThis is the %dth product you have searched!,m);getch();开始menu();3 .新物资入库模块insert。/*新物资入库模块*/ int n,c;n=load();
14、puts(nInput one data:n);doinput(n); printf_data(n);printf(nnAre you sure?n1).suren2). cancel and againn3).back without sav scanf(%d,&c);if(c=1)save(n+1);printf_back(); else if(c=3)menu();while(c=2);min_s,&proi.real_s,&proi.max_s);图(5)新物资入库模块4 .领料模块lend()/*领料模块*/int j,n;n=load();printf(nPlease check
15、the products data you lend!);printf(nname(1-20letter) size(1-4letter) date amountn);scanf(%s%s%d.%d.%d%d,&check.p_name,&check.size,&check.l_date.year,&check.l_date .month,&check.l_date.day,&check.total);for(j=0;jn;j+)if(strcmp(check.p_name,proj.p_name)=0)&(strcmp(check.size,proj.size)=0)&(che ck.l_d
16、ate.year=proj.in_date.year)&(check.l_date.month=proj.in_date.month)&(check.l_ date.day=proj.in_date.day)&(check.total=proj.real_s)proj.real_s-=check.total;save(proj.real_s);printf_data(j); printf_back();else printf(Erro!);5 .打印模块print()/*打印模块*/ int i,n;n=load();for(i=0;in;i+)printf_data(i);getch();
17、menu();6 .采用文件来存储数据信息#includesave(int n)FILE*fp;int k;if(fp=fopen(pro.dat,wb)=NULL) printf(nCannot open file!n);return NULL;for(k=0;k:cccnumbeF(i-71ettei,):5siae(l-41etter):3date:2010.09.03min_s real_s max_s:1 3 8namenunsizedatenin realmaxc438520432010.9.31-3-8fire you sure?1).sure.cancel and again
18、.back uithout saue 1 Guccessful?Thank you!ca -I:W3I(31程设计Iklm苴12.图(12)新物资入库模块口区lease check the productJ s data you lendf ame(l-201ettep) si2e(l-41ettep) date amount aa 1 010.09.01 3amenumsizedatemin realmaxaa4385044i2010.9.1i-2-9uccessful!Thank you,图(13)领料模块图(14)打印模块六.总结在学习C语言这门课时,由于是第一次接触计算机的课程,而且这
19、门课本来就很抽象,因此,上课时就觉得听不懂.上程序设计课时也是一知半解,加上 设计课的时间短,所以自己也没有什么进步。老师布置课程设计后,通过不断的学习与实践,慢慢有了一些进步,自己在 综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的方面有了很 大的提高。当今科学技术发展日新日异,计算机应用在生活中更是无处不在。 作 为一个大学来说掌握计算机技术是十分重要的。回顾这次的课程设计,我感慨良多。从题目到编程,再从编程到调试,我学 到很多很多的的东西,通过这次课程设计,我懂得了学习计算机靠的是大量的上 机编程调试,从中才可以不断提高编程水平。 在设计的过程中,我遇到了很多问 题,这毕
20、竟第一次做的,难免会遇到过各种各样的问题,比如说结构体、调试不 成功我很高兴在我遇到困难的时候,同学们给了我很多的帮助,可以这么说,没 有同学们,我现在肯定还没有完成这次课程设计。在设计中遇到了很多编程问题, 在同学的帮助下,最后都迎刃而解。最后,我要再次对各位同学和曹弘老师说一 声,谢谢大家的帮助,谢谢!附录:源程序#include#include#define N 100 struct dateint year;int month;int day;struct productchar p_name20;/* 物资名称 */ long int p_num7;/* 物资编号 */ char s
21、ize4;/*物资规格 */ struct date in_date;/*货日期 */ long int max_s;/*最大库存量 */ long int min_s;/* 最小库存量 */ long int real_s;/*实际库存量 */ struct product *next;/*结点指针 */*主函数*/proN;menu()int n,w1;doputs(ttt*menu*nn);puts(ttt 1.enter new datann);/*输入数据 */puts(ttt 2.search menunn);/*S 找信息*/puts(ttt 3.insert new datan
22、n);/*插入新数据 */puts(ttt 4.lend datann);/*领料数据 */puts(ttt5.print datann);/* 打印*/puts(ttt 6.exit);/* 退出*/puts(nttt*n);printf(Please choose the number 1-6: bb);scanf(%d,&n);if(n6)w1=1;getchar(); else w1=0;while(w1=1);switch(n)case 1:enter();break;case 2:search();break;case 3:insert();break;case 4:lend();
23、break;case 5:print();break;case 6:exit(0);main()menu(); enter()/*信息输入模块*/int i,n;printf(nHow many products do you want to input(0-%d)?:,N-1);scanf(%d,&n);printf(nEnter data now!nn);for(i=0;in;i+)printf(Please input the %dth products data:n,i+1);input(i);if(i!=0)save(n);printf_back();.search。/*信息查找模块
24、*/int n,w2;doputs(ttt*search menu*nn);puts(ttt1.search by name);puts(ttt2.search by data);puts(ttt3.search by name and size);puts(ttt4.exit);puts(nttt*n);printf(Choose the number to search 1-4: bb);scanf(%d,&n);if(n4)w2=1;getchar();else w2=0;while(w2=1);switch(n)case 1:search_by_name();break;case 2:
25、search_by_date();break;case 3:search_by_nameandsize();break;case 4:getch();menu();search_by_name()/校名称查找 */int j,n,m=0;char a20;n=load();printf(nInput the products namenname:);scanf(%s,a);for(j=0;jn;j+)if(strcmp(a,proj.p_name)=0)m+;printf_data(j);printf(nThis is the %dth product you have searched!,m
26、);getch();menu();struct s_date/眩 日期查找*/int year;int month;int day;s;search_by_date()int j,n,m=0;n=load();printf(nInput the date(*.*.*)ndate:);scanf(%d.%d.%d,&s.year,&s.month,&s.day);for(j=0;jn;j+)if(s.year=proj.in_date.year)&(s.month=proj.in_date.month)&(s.day=proj .in_date.day)m+;printf_data(j);.pr
27、intf(nThis is the %dth product you have searched!,m);getch();menu();search_by_nameandsize()微名称和规格查找 */int j,n,m=0;char a20,b4;n=load();printf(nInput the products namenname:);scanf(%s,a);printf(nInput the products sizensize:);scanf(%s,b);for(j=0;jn;j+)if(strcmp(a,proj.p_name)=0)&(strcmp(b,proj.size)=
28、0) m+;printf_data(j);.printf(nThis is the %dth product you have searched!,m);getch();menu();insert。/*新物资入库模块*/int n,c;n=load();puts(nInput one data:n);doinput(n);printf_data(n);printf(nnAre you sure?n1).suren2).cancel and againn3).back without save bb);scanf(%d,&c);if(c=1)save(n+1);printf_back();els
29、e if(c=3)menu();while(c=2);struct l_prochar p_name20;char size4;struct date l_date;long int total;struct l_pro *next;check;lend()/*领料模块*/int j,n;n=load();printf(nPlease check the products data you lend!);printf(nname(1-20letter) size(1-4letter) date amountn);scanf(%s%s%d.%d.%d%d”,&check.p_name,&chec
30、k.size,&check.l_date.year,&chec k.l_date.month,&check.l_date.day,&check.total);for(j=0;jn;j+)if(strcmp(check.p_name,proj.p_name)=0)&(strcmp(check.size,proj.size)=0) &(check.l_date.year=proj.in_date.year)&(check.l_date.month=proj.in_date. month)&(check.l_date.day=proj.in_date.day)&(check.total=proj.real_s)proj.real_s-=check.total;save(proj.real_s);printf_data(j);printf_back();else printf(Erro!);print()/*打印模块*/ int i,n;n=load();for(i=0;in;i+) printf_data(i); getch();menu();/*保存函数,保存n个记录*/#include save(int n)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二手房家具合同
- 外墙瓷砖合同
- 独角兽基金合同
- 2026秋季国家管网集团工程技术创新公司(国家管网集团造价管理中心)高校毕业生招聘笔试参考题库(浓缩500题)附答案详解【完整版】
- 工程增减合同
- 英文佣金合同
- 国家管网集团山东分公司2026届秋季高校毕业生招聘笔试模拟试题(浓缩500题)含答案详解(基础题)
- 2025至2030共挤出医疗管行业发展趋势分析与未来投资战略咨询研究报告
- 取消修船合同
- 2025国网山西高校毕业生提前批招聘(约450人)笔试模拟试题浓缩500题及一套参考答案详解
- 反保险欺诈主题教育课件
- 2024年中国人民财产保险股份有限公司招聘笔试参考题库含答案解析
- 《环境监测奚旦立》课件
- 孕产期药物使用的安全性
- 【数学】山西省太原市2024届高三上学期期中试题(解析版)
- 外研版英语五年级上册 Module 7
- 提高新生儿出生24小时母乳喂养及时率PDCA
- 七年级生物上册动物的主要类群复习课件
- 江苏省徐州市邳州市 2023-2024学年七年级上学期11月期中道德与法治试题
- NUDD新独难异 失效模式预防检查表
- 化学沉淀及氧化还原法课件
评论
0/150
提交评论