收藏 分销(赏)

算法与数据结构课程设计仓库货品管理(常用版).doc

上传人:二*** 文档编号:4534691 上传时间:2024-09-27 格式:DOC 页数:102 大小:3.92MB
下载 相关 举报
算法与数据结构课程设计仓库货品管理(常用版).doc_第1页
第1页 / 共102页
亲,该文档总共102页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、算法与数据结构课程设计仓库货品管理(常用版)(可以直接使用,可编辑 完整版资料,欢迎下载)*实践教学* 兰州理工大学计算机与通信学院2021年春季学期 算法与数据结构 课程设计题 目: 仓库货品管理 专业班级:08级计算机科学与技术5班姓 名: 马菁 学 号: 08240507 指导教师: 李 睿 成 绩:_ 目 录摘 要3前 言4正 文51.采用类c语言定义相关的数据类型5 2.各模块的伪码算法.53.函数的调用关系图124.调试分析135.测试结果13 6.源程序(带注释).16总 结28参考文献30致 谢31附 件部分源程序代码32摘 要本文介绍了小型仓库管理系统的设计与实现。通过对仓库

2、基本功能的分析,该程序实现了对小型仓库管理的基本操作。设计要求主要是货品入库、出库、查找及显示库存量等最基本功能操作。在课程设计过程中,对问题的所采用的数据结构和算法分析,及程序设计语言采用VC,程序运行的平台是WindowsXP(visual C+6.0),逐步对基本要求进行分布实现,在设计中采用单链表和文件对录入的基本数据进行存储,最终对产品进行的基本操作如产品入库、出库及查找都基本以实现。该小型仓库管理系统的界面可视化程度较高,操作者和使用者使用较为便。 关键字: 仓库货品管理 ;单链表 ;数据结构和算法;前 言 我们对教学计划有一个系统的认识,大学的每个专业都要制定教学计划。假设任何专

3、业都有固定的学习年限,每学年含两学期,每学期的时间长度和学分上限值均相等。每个专业开设的课程都是确定的,而且课程在开设时间的安排必须满足先修关系。每门课程有哪些先修课程是确定的,可以有任意多门,也可以没有。每门课恰好占一个学期。试在这样的前提下设计一个教学计划编制程序。通过该题目的设计过程,可以加深理解数据的逻辑结构、存储结构,掌握线性表上基本运算的实现,进一步理解和熟练掌握课本中所学的各种数据结构,学会如何把学到的知识用于解决实际问题,培养学生的动手能力。通过本次课程设计的制作,能让我们对数据结构以及程序设计有更深的体会,流程图的建立能提高我们系统分析问题的能力,从而灵活的驾驭整个程序的运行

4、,通过对图的顶点的存储,让我们加深对邻接表的应用,更重要的是拓扑排序的复习,大一时,我们曾在离散数学中学习了拓扑排序,此次课程设计不仅能让我们学习数据结构的知识,同时也能让我们系统复习一下图论的知识。 正文 1. 采用类c语言定义相关的数据类型menu_init ()+新建仓库 newstore()+打开仓库 openstore()+添加货物 addproduct() +修改货物 editproduct() +删除货物 delproduct() +库存管理 menu_store()-货物出库 instore()-货物进库 outstore() +货物查询 menu_check() +按编号查询

5、 bynumber() +按名称查询 byname() +储存数据 savedata()+所有货物 listall() +退出系统 exit()1.2数据设计商品结构体设计:struct Productint num;char name20;float rice;int amount;struct *next; 2各模块的伪码算法:2.1菜单类:menu_init();说明:初始化界面menu_store();说明:库存管理界面menu_check();说明:货物查询界面menu exit();说明:退出界面2.2货物管理类:addproduct( struct Product *head )

6、;说明: struct Product *head 为要添加节点的链表功能:添加货物流程图:editproduct( struct Product *head );说明: struct Product *head 为要修改节点的链表功能:修改货物流程图:delproduct( struct Product *head );说明: struct Product *head 为要修改节点的链表功能:删除货物流程图:instore( struct Product *head );说明: struct Product *head 为要修改节点的链表功能:修改货物outstore( struct Pro

7、duct *head );说明: struct Product *head 为要修改节点的链表功能:修改货物outinstore( struct Product *head, int ouin );说明: struct Product *head 为要修改节点的链表功能:出库进库综合操作类2.3货物查询类:bynumber( struct Product *head, int num );说明: struct Product *head 为要修改节点的链表, num 为商品编号功能:按编号查询商品byname( struct Product *head, char *name );说明: st

8、ruct Product *head 为要修改节点的链表, name 为商品名称功能:按名称查询商品listall( struct Product *head );说明: struct Product *head 为要显示链表功能:显示所有商品流程图:2.4仓库管理类:openstore( );说明: 打开仓库数据文件到链表功能:打开仓库文件NS流程图:struct Product *h = NULL;filename01.2 1.4 1.6 1.7 1.8 1.9 1.10 2.1 2.4 3.1 3.2 3.5 4.1 4.2 4.3 5.1 5.2 5.3 5.4 6.2 6.3 输入文

9、件名filenamefp = fopen (filename,”rb”)TFwhile( !feof(fp) )fread( pd, Length, 1, fp )Freturn h;return h;q = pd;pd = pd -next;break;q-next; return h;savedata( );说明: 写仓库链表数据到文件功能:储存货品数据2.5辅助类:cls( );说明: 换行功能:换行3. 函数的调用关系图:四、五、调试分析与结果:1 程序运行时初始界面2 新建仓库用键盘输入1,程序调用新建仓库功能函数,要求用户输入货物编号,货物名称,货物价格等。3 打开仓库文件用键盘输

10、入2,程序调用打开仓库文件功能函数,要求用户输入仓库数据文件名,数据文件存在,显示打开成功。4 添加货物用键盘输入3,程序调用添加货物功能函数,要求用户输入货物编号,货物名称,货物价格等。5 修改货物用键盘输入4,程序调用修改货物功能函数,要求用户输入货物编号,货物存在,显示货物详细信息,按任意键后,要求用户输入新货物名称,货物价格等。6 删除货物用键盘输入5,程序调用删除货物功能函数,要求用户输入货物编号,货物存在,显示货物详细信息,按任意键后,删除货物。7 库存管理:用键盘输入6,程序调用库存管理功能函数,显示库存管理子页面,选择2,货物出库,要求用户输入货物编号,货物存在,显示货物详细信

11、息,要求用户输入进库数量。8 货物查询用键盘输入7,程序调用货物查询功能函数,显示货物查询子页面,选择1,按编号查询,要求用户输入货物编号,货物存在,显示货物详细信息。货若物不存在,显示“没有该编号货物”。9 储存数据用键盘输入8,程序调用储存数据功能函数,要求用户输入文件名,将数据储存在指定文件中。10 所有货物用键盘输入9,程序调用所有货物功能函数,显示仓库内所有货物。11 退出系统用键盘输入0,程序调用货退出系统功能函数,显示提示保存信息。6.源程序(带注释):#include #include /*#include */#include #include #define Length

12、sizeof( struct Product )/*定义货品结构体*/struct Product int num; char name20; float rice; int amount; struct Product *next;void cls( void ) int i; for( i=0; inext = (struct Product *)malloc( Length ); if( pd-next = NULL ) printf(内存溢出n); / getch(); return(h); q = pd; pd = pd-next; q-next = NULL; fclose( fp

13、 ); printf(成功打开仓库数据文件n); / getch(); return(h);int savedata( struct Product *head ) char filename255; struct Product *pd; FILE *fp; pd = head; printf(请输入要保存的仓库数据文件名(如:store,0取消):n); scanf(%s, &filename); if( filename0 = 0 ) return 1; if( (fp=fopen(filename, wb) ) = NULL ) printf(储存文件出错n); / getch();

14、return 1; printf(正在储存数据.n); while( pd!=NULL ) fwrite( pd, Length, 1, fp); pd = pd-next; fclose( fp ); printf(仓库数据保存成功n); / getch(); return 0;/*/创建链表,新建一个仓库,并输入数据/返回链表*/struct Product *newstore() struct Product *h = NULL, *pd; for(;) pd = (struct Product *)malloc( Length ); if (!pd) printf(内存溢出!n); /

15、 getch(); return NULL; printf(请输入货品编号(0退出):n); scanf(%d, &pd-num); if( pd-num = 0 ) break; printf(请输入货品名称:n); scanf(%s, &pd-name); printf(请输入货品价格:n); scanf(%f, &pd-rice); printf(请输入货品库存量:n); scanf(%d, &pd-amount ); printf(n); pd-next = h; h = pd; return(h);/*/添加货品,向链表末尾添加货品/参数:*head链表指针/返回添加货品的链表*/s

16、truct Product *addproduct( struct Product *head ) struct Product *h, *pd; if( !head ) printf(请先创建或打开仓库n);return head; else h = head; for(;) pd = (struct Product *)malloc( Length ); if (!pd) printf(内存溢出!n); / getch(); break; printf(请输入货品编号(0退出):n); scanf(%d, &pd-num); if( pd-num = 0 ) break; printf(请

17、输入货品名称:n); scanf(%s, &pd-name); printf(请输入货品价格:n); scanf(%f, &pd-rice); printf(请输入货品库存量:n); scanf(%d, &pd-amount ); printf(n); while( h-next!=NULL ) h = h-next; h-next = pd; pd-next = NULL; return(h);/*/按编号查找货品/参数:*head链表指针,*num货品编号/返回:链表结点*/struct Product *bynumber( struct Product *head, int num )

18、float total; int n = num; struct Product *pd; pd = head; while( pd!=NULL&pd-num!=n) pd = pd-next; if( pd = NULL) printf(没有该编号货品。n); / getch(); else printf(t*按编号查询货品*n); printf(t| 编号 | 名称 | 价格 | 库存 | 价值量 |n); printf(t|-|-|-|-|-|n); printf(t|%6d|%-13s|%9.3f|%8d|, pd-num, pd-name, pd-rice, pd-amount);

19、total = pd-rice * pd-amount; printf(%9.3f|n, total); printf(t*n); / getch(); return(pd);/*/按名称查找货品/参数:*head链表指针,*name货品名称/返回:链表结点*/struct Product *byname( struct Product *head, char name20 ) float total; struct Product *pd; pd = head; while( pd!=NULL&strcmp(pd-name, name)!=0) pd = pd-next; if( pd =

20、NULL) printf(没有该名称货品。n); / getch(); else printf(t*按名称查询货品*n); printf(t| 编号 | 名称 | 价格 | 库存 | 价值量 |n); printf(t|-|-|-|-|-|n); printf(t|%6d|%-18s|%9.3f|%8d|, pd-num, pd-name, pd-rice, pd-amount); total = pd-rice * pd-amount; printf(%9.3f|n, total); printf(t*n); / getch(); return(pd); void *checkbynumbe

21、r( struct Product *head ) struct Product *h = head; int num; printf(请输入查询编号(0退出):n); scanf(%d, &num); return bynumber( h, num); void *checkbyname( struct Product *head ) struct Product *h = head; char name20; printf(请输入货品名称(0退出):n); scanf(%s, &name); return byname( h, name);/*/修改货品/参数:*head链表指针/返回:链

22、表结点*/struct Product *editproduct( struct Product *head ) int num; struct Product *h, *pd; h = head; for(;) pd = (struct Product *)malloc( Length ); if (!pd) printf(内存溢出!n); / getch(); break; printf(请输入要修改的货品编号:(0退出)n); scanf(%d, &num); if( num = 0 ) break; pd = bynumber( h, num); if( pd = NULL) brea

23、k; printf(请输入货品新名称:n); scanf(%s, &pd-name); printf(请输入货品新价格:n); scanf(%f, &pd-rice); printf(n); return(h);struct Product *delproduct( struct Product *head ) int num; char confirm; struct Product *h, *q, *pd; pd = q = h = head; for(;) printf(请输入要删除的货品编号:(0退出)n); scanf(%d, &num); if( num = 0 ) break;

24、while( pd!=NULL&pd-num!=num) q = pd; pd = pd-next; if( pd = NULL) printf(没有该编号货品。n); else bynumber( h, num); / getch(); if(pd=h) /*如果p=h,说明被删结点是头结点*/ h=pd-next; /*修改头指针指向下一条记录*/ else q-next=pd-next; printf(删除成功n); return(h);/*/货品进库出库/参数:*head链表指针, *outin为进库出库类型,0表示出库/返回:链表结点*/struct Product *outinst

25、ore( struct Product *head, int outin ) int num, outnum; struct Product *h, *pd; h = head; for(;) pd = (struct Product *)malloc( Length ); if (!pd) printf(内存溢出!n);/ getch(); break; printf(请输入要修改的货品编号:(0退出)n); scanf(%d, &num); if( num = 0 ) break; pd = bynumber( h, num); if(!pd) break; if( outin = 0)

26、printf(请输入货品出库数量:n); scanf(%d, &outnum); pd-amount = pd-amount - outnum; else printf(请输入货品进库数量:n); scanf(%d, &outnum); pd-amount = pd-amount + outnum; printf(n); return(h);/*/货品出库*/struct Product *outstore(struct Product *head) struct Product *h = head; return outinstore(h, 0);/*/货品进库 */struct Produ

27、ct *instore(struct Product *head) struct Product *h = head; return outinstore(h, 1); void listall( struct Product *head) float total=0, all=0; struct Product *pd; pd = head; if( pd = NULL ) cls(); printf(错误:当前未打开任何仓库n); / getch(); return; cls(); printf(t*仓库内所有货品*n); printf(tt| 编号 | 名称 | 价格 | 库存 | 价值

28、量 |n); printf(tt|-|-|-|-|-|n); do printf(tt|%6d|%-13s|%9.3f|%8d|, pd-num, pd-name, pd-rice, pd-amount); total = pd-rice * pd-amount; all+= total; printf(%9.3f|n, total); pd = pd-next; while(pd!=NULL); printf(t*n); printf(t仓库货品总价值量为:%12.3f元n, all); printf(t*n); / getch();void menu_store( struct Produ

29、ct *head ) int select; for(;) printf(t*n); printf(tt算法与数据结构课程设计-仓库货品管理n); printf(t*n); printf(tttt1.货品出库n); printf(tttt2.货品进库n); printf(tttt0.返 回n); printf(t*n); printf(请选择操作:); scanf(%d, &select); switch(select) case 0: return; case 1: head = outstore(head); break; case 2: head = instore(head); voi

30、d menu_check( struct Product *head ) int select; for(;) printf(t*n); printf(tt算法与数据结构课程设计-仓库货品管理n); printf(t*n); printf(tttt1.按编号查询n); printf(tttt2.按名称查询n); printf(tttt0.返 回n); printf(t*n); printf(请选择操作:); scanf(%d, &select); switch(select) case 0: return; case 1: checkbynumber( head ); break; case 2

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服