数据结构课程设计书店仓库管理系统.doc

上传人:土8路 文档编号:10222897 上传时间:2021-04-30 格式:DOC 页数:73 大小:586.50KB
返回 下载 相关 举报
数据结构课程设计书店仓库管理系统.doc_第1页
第1页 / 共73页
数据结构课程设计书店仓库管理系统.doc_第2页
第2页 / 共73页
数据结构课程设计书店仓库管理系统.doc_第3页
第3页 / 共73页
数据结构课程设计书店仓库管理系统.doc_第4页
第4页 / 共73页
数据结构课程设计书店仓库管理系统.doc_第5页
第5页 / 共73页
点击查看更多>>
资源描述

《数据结构课程设计书店仓库管理系统.doc》由会员分享,可在线阅读,更多相关《数据结构课程设计书店仓库管理系统.doc(73页珍藏版)》请在三一文库上搜索。

1、课程设计说明书 NO.1 书店仓库管理系统1. 课程设计目的本课程设计是为了配合数据结构课程的开设,通过设计一个完整的程序,使学生掌握数据结构的应用、算法的编写、C语言的算法转换成C程序并用TC上机调试的基本方法。加深对数据结构的理解,提高算法设计的能力,锻炼编程的能力。2. 设计方案论证2.1 设计目标2.1.1 设计任务对稀疏矩阵进行加减乘的运算。当输入两个矩阵时,可以对,即实现图书入库。当有图书卖出时,管理人员可查阅目前此类图书的库存情况,如图书还有存量,管理人员可根据不同的出价调出相应价的图书,也可以根据市场波动对图书做出相应的调价。当图书出现问题,需要退给供货商时,管理员可以把退还的

2、书名,数量,金额,记录下来。当月底或年终时,管理人员可以将各种图书的出入库,库存金额整理出来,以便查看。2.1.2 设计要求该程序采用了线性链表的存储结构来设计以及实现对于书店仓库的信息管理。在对链表的设计中具体采用了设置头指针的单向链表的存储方式。对于插入、查找、删除等功能要求能按书名,编号进行。图书信息包括:图书编号、书名、规格、数量、进货价、销售价。2.2 需求分析书店仓库管理系统要求实现许多功能,可遵循结构化程序设计思想来进行本系统的设计自顶向下,逐步细化,也就是将软件设计任务划分成许多容易解决的小的子任务,即分解出许多子功能模块进行设计。本程序经过分析分为以下几个模块:入库操作、出库

3、操作、退货操作及进行统计操作。 沈 阳 大 学课程设计说明书 NO.2本程序采用了线性链表的存储结构来设计以及实现对于书店仓库的信息管理。在对链表的设计中具体采用了单向链表的存储方式。用4个结构数组(或链表)来存储下述4类信息,每类信息的每条记录用结构类型自定义: 1图书信息:图书编号、书名、规格、数量、进货价、销售价;2入库信息:入库编号、图书编号、入库图书名、入库数量、入库价格、总价;3出库信息:出库编号、图书编号、出库图书名、出库数量、出库价格、总价;4退货信息:退货编号、图书编号、退还图书名、退货数量、退货价格、总价;5. 对以上每类信息建立数据结构; 6. 对以上每类信息进行插入操作

4、; 7. 对以上每类信息进行删除操作; 8. 对以上每类信息进行修改操作;9. 对以上每类信息进行查找操作(查找关键字用下划线标出); 10. 数据统计:(1)统计入库图书的总数及总价; (2)统计出库图书的总数及总价;(3)统计仓库中现有图书的总数及总价格。2.3 设计方法2.3.1 数据设计(1)数据结构的选择选取动态数据结构,本系统是通过带有头指针的单向链表来完成的。动态存储分配与释放 申请存储空间函数malloc( )函数首部原型为void * malloc(unsigned int size) 沈 阳 大 学课程设计说明书 NO.3 释放存储空间函数free( )函数首部原型为voi

5、d free(void*p)(2)数据类型的选择struct book /*定义链表结构体*/char p_num12; /*图书编号*/char name12; /*书名*/char spec12; /*规格*/int amount; /*数量*/int price; /*进货价格*/int s_price; /*销售价*/struct book *next; /*定义指针,指向后继*/(3)变量函数说明init() 输入图书信息菜单menu() 选择对图书操作的菜单menu2() 返回选择界面in_insert() 向入库图书中插入图书信息in_modify() 修改入库的图书信息in_s

6、elect() 查找入库图书的信息in_delete() 删除入库图书的信息out_insert() 向出库图书中插入图书信息out_modify() 修改出库图书的信息 out_select() 查找出库图书的信息out_delete() 删除出库图书的信息quit_insert() 向退货图书中插入图书信息quit_modify() 修改退货图书的信息quit_select() 查找退货图书的信息 沈 阳 大 学课程设计说明书 NO.4quit_delete() 删除退货图书的信息2.3.2 系统结构图系统整体结构图如下图1所示开始输出menuSwitchN=0N=4N=3N=1N=2进行

7、图书统计操作进行图书退货操作进行图书出库操作进行图书入库操作退出输出统计结果图1 系统整体结构图 沈 阳 大 学课程设计说明书 NO.52.3.3 模块设计与介绍对本系统的功能进行分析后可作如下的模块化设计图书入库模块的实现:(1) 插入图书信息:按顺序将入库编号、图书编号、入库图书名、入库数量、入库价格、总价依次输入,并建立链表将其连接;(2) 删除图书信息:输入图书入库编号,将其内容删除;(3) 修改图书信息:输入图书入库编号,修改其对应信息的内容;(4) 查找图书信息:输入图书入库编号,显示其对应信息。图书出库模块的实现:(1) 插入图书信息:按顺序将出库编号、图书编号、出库图书名、出库

8、数量、出库价格、总价依次输入,并建立链表将其连接;(2) 删除图书信息:输入图书出库编号,将其内容删除;(3)修改图书信息:输入图书出库编号,修改其对应信息的内容;(4)查找图书信息:输入图书出库编号,显示其对应信息。图书退货模块的实现:(1)插入图书信息:按顺序将退货编号、图书编号、退货图书名、退货数量、退货价格、总价依次输入,并建立链表将其连接;(2)删除图书信息:输入图书退货编号,将其内容删除;(3)修改图书信息:输入图书退货编号,修改其对应信息的内容;(4)查找图书信息:输入图书退货编号,显示其对应信息。图书统计模块的实现:(1)统计入库商品的总数及总价 (2)统计出库商品的总数及总价

9、 (3)统计仓库中现有商品的总数及总价格 沈 阳 大 学课程设计说明书 NO.62.3.4 主要模块程序流程图开始分配空间p=p-nextp=head Yp-next!=NULLP=NULL N Y Np-next=p1输入图书信息输入图书信息head=p1;head-next=NULL;结束图2 关于insert()的流程图 沈 阳 大 学课程设计说明书 NO.7 开始创建指针P=ihead输入选择书号P!=NULLp=p-next N Ystrcmp(p-num,s_num)=0 N Y输出信息结束图3 关于select()的流程图 沈 阳 大 学课程设计说明书 NO.82.4 算法设计2

10、.4.1 定义结构体struct book char p_num12; char name12; char spec12; int amount; int price; int s_price; struct book *next; ;2.4.2模块设计(1)插入信息模块insert():首先需要建立一个链表。建立链表的具体操作就是逐一输入各结点数据,并建立其前后相链的关系。首先建立带表头结点的单链线性表p1,以及指针点p。用malloc函数开辟一个结点,将表头赋给p,使用if语句对表头进行判断。如果表头为空,即表示链表现在为空,通过printf语句提示需要往链表中输入数据,通过scanf语句

11、向链表中输入图书的信息赋给头指针并使头指针所指向的后继结点为空,然后返回上层菜单。如果表头不为空,通过使用while循环语句将p指针依次往后移,直至后继结点为空,即将指针p移到链表末端,在链表末端插入数据,输入数据,并返回。int in_insert() struct in_book * p1,* p; p1=(struct in_book *)malloc(sizeof(struct in_book); p=ihead; if (p=NULL)/*开始没有数据*/ printf(Iuput the data of in bookn); 沈 阳 大 学课程设计说明书 NO.9printf(In

12、clude the rkbh,spbh,name,number,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); ihead=p1; ihead-next=NULL; return 0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Iuput the datan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&

13、p1-name,&p1-amount,&p1-price,&p1-t_price); p1-next=NULL; (2)查找信息模块delete(): 首先定义一个数组以及指针p,将头指针赋给p,通过循环语句while进行循环,判断跳出循环语句为p不为空。在循环体内,首先判断指针所指向的值是否为所查找的值,若是,则通过printf语句输出所查找信息,若不是,则将指针赋给其后继结点继续比较,当p指针所指向的结点为空,则跳出循环,执行printf语句提示用户所查找的数据未找到。int in_select() char s_num12; struct in_book * p; p=ihead; 沈

14、阳 大 学课程设计说明书 NO.10printf(Iuput the select numn); scanf(%s,&s_num); while(p!=NULL) if (strcmp(p-num,s_num)=0) printf(The data you want is:n); printf( %s %s %s %d %d %dn, p-num,p-p_num,p-name,p-amount,p-price,p-t_price); return 0; p=p-next; printf(Sorry! No num has foundn); (3)修改信息模块 modify():首先定义一个数组

15、以及指针p,将头指针赋给p,通过printf语句提示输入所要修改的数据编号,再通过scanf语句输入编号。然后使用if语句对指针所指向的首结点进行判断,若该结点为空节点,则通过printf语句提示该链表为空,无数据并返回上层菜单。若该结点有数据,则将该结点的数据与所要修改数据的结点进行比较,若为修改结点,则将修改后的值赋给原值,实现修改并返回上层菜单,若不能找到修改结点则将指针向后继结点移动,并继续比较直至链表最尾端,若还未找到修改结点,则通过printf语句提示用户未能找到结点。int in_modify() char m_num12; struct in_book * p; p=ihead

16、; printf(Iuput the modify numn); scanf(%s,&m_num);if (p=NULL)/*开始没有数据*/ printf(Sorry! No data can be foundn); 沈 阳 大 学课程设计说明书 NO.11 return 0; while(p!=NULL) if (strcmp(p-num,m_num)=0) printf(Iuput the new data without numn); scanf(%s%s%d%d%d, &p-p_num,&p-name,&p-amount,&p-price,&p-t_price); printf(On

17、e data had modifiedn); return 0; p=p-next; printf(Sorry! No num has foundn); (4)删除信息模块首先定义一个数组以及指针p1、p,将头指针赋给p,输入所要删除数据的编号,对链表进行判断,若为空,则提示用户没有数据并返回上层菜单,若不为空,则对指针所指向的数据编号与所要删除的数据编号进行比较,若为该值,则进行删除。若不是,则将指针依次向后移动直至链表尾端,若还未找到要删除数据,使用printf语句提示用户为找到数据。int in_delete() char d_num12; struct in_book * p1,* p

18、; p=ihead; printf(Iuput the delete numn); scanf(%s,&d_num); if (p=NULL)/*开始没有数据*/ printf(No data can be foundn); return 0; 沈 阳 大 学课程设计说明书 NO.12if (strcmp(p-num,d_num)=0 & p-next=NULL)/*链表只有一个数据,且是要删除的*/ ihead=NULL; printf(One data has been deletedn); return 0; if (strcmp(p-num,d_num)=0 & p-next!=NUL

19、L)/*要删除的数据在链表的头上*/ ihead=ihead-next;printf(One data has been deletedn); return 0; while(p-next!=NULL) p1=p-next; if (strcmp(p1-num,d_num)=0) p-next=p1-next; printf(One data has been deletedn); return 0; p=p-next; printf(Sorry! No num has foundn); 2.5 源程序#include #include struct book char p_num12;cha

20、r name12; char spec12; int amount; int price; int s_price; struct book *next; ; 沈 阳 大 学课程设计说明书 NO.13struct book *head;struct in_book char num12; char p_num12; char name12; int amount; int price; int t_price; struct in_book *next;struct in_book *ihead;struct out_book char num12; char p_num12; char na

21、me12; int amount; int price; int t_price; struct out_book *next; ;struct out_book *ohead;struct quit_book char num12; char p_num12; char name12; int amount; int price; int t_price; struct quit_book *next; ; 沈 阳 大 学课程设计说明书 NO.14struct quit_book *qhead;int init() head=ihead=ohead=qhead=NULL;printf(*);

22、 printf(0: Quitn); printf(1: Iuput the information of in bookn); printf(2: Iuput the information of out bookn); printf(3: Iuput the information of quit bookn); printf(4: Total the information of bookn);printf(*); int menu() printf(*);printf(1:insert datan); printf(2:delete datan); printf(3:modify da

23、tan); printf(4:select datan); printf(Other to quitn); printf(*);int menu2() printf(*);printf(0: Quitn); printf(1: Iuput the information of in bookn); printf(2: Iuput the information of out bookn); printf(3: Iuput the information of quit bookn); printf(4: Total the information of bookn); printf(*); 沈

24、 阳 大 学课程设计说明书 NO.15int in_insert() struct in_book * p1,* p; p1=(struct in_book *)malloc(sizeof(struct in_book); p=ihead; if (p=NULL)/*开始没有数据*/ printf(Iuput the data of in bookn); printf(Include the rkbh,spbh,name,number,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&

25、p1-price,&p1-t_price); ihead=p1; ihead-next=NULL; return 0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Iuput the datan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); p1-next=NULL; int in_modify() char m_num12; struct in_book * p; p=ihe

26、ad; printf(Iuput the modify numn); scanf(%s,&m_num); if (p=NULL)/*开始没有数据*/ printf(Sorry! No data can be foundn); return 0; 沈 阳 大 学课程设计说明书 NO.16while(p!=NULL) if (strcmp(p-num,m_num)=0) printf(Iuput the new data without numn); scanf(%s%s%d%d%d, &p-p_num,&p-name,&p-amount,&p-price,&p-t_price); printf(

27、One data had modifiedn); return 0; p=p-next; printf(Sorry! No num has foundn); int in_select() char s_num12; struct in_book * p; p=ihead; printf(Iuput the select numn); scanf(%s,&s_num); while(p!=NULL) if (strcmp(p-num,s_num)=0) printf(The data you want is:n); printf( %s %s %s %d %d %dn, p-num,p-p_n

28、um,p-name,p-amount,p-price,p-t_price); return 0; p=p-next; printf(Sorry! No num has foundn); int in_delete() char d_num12; struct in_book * p1,* p; p=ihead; 沈 阳 大 学课程设计说明书 NO.17printf(Iuput the delete numn); scanf(%s,&d_num); if (p=NULL)/*开始没有数据*/ printf(No data can be foundn); return 0; if (strcmp(

29、p-num,d_num)=0 & p-next=NULL)/*链表只有一个数据,且是要删除的*/ ihead=NULL; printf(One data has been deletedn); return 0; if (strcmp(p-num,d_num)=0 & p-next!=NULL)/*要删除的数据在链表的头上*/ ihead=ihead-next; printf(One data has been deletedn); return 0; while(p-next!=NULL) p1=p-next; if (strcmp(p1-num,d_num)=0) p-next=p1-ne

30、xt; printf(One data has been deletedn); return 0; p=p-next; printf(Sorry! No num has foundn); int out_insert() struct out_book * p1,* p; p1=(struct out_book *)malloc(sizeof(struct out_book); p=ohead; if (p=NULL)/*开始没有数据*/ 沈 阳 大 学课程设计说明书 NO.18printf(Iuput the data of out bookn); printf(Include the ck

31、bh,spbh,name,number,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); ohead=p1; ohead-next=NULL; return 0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Iuput the datan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-

32、amount,&p1-price,&p1-t_price); p1-next=NULL; int out_modify() char m_num12; struct out_book * p; p=ohead; printf(Iuput the modify numn); scanf(%s,&m_num); if (p=NULL)/*开始没有数据*/ printf(Sorry! No data can be foundn); return 0; while(p!=NULL) if (strcmp(p-num,m_num)=0) printf(Iuput the new data without

33、 numn); scanf(%s%s%d%d%d, 沈 阳 大 学课程设计说明书 NO.19&p-p_num,&p-name,&p-amount,&p-price,&p-t_price); printf(One data had modifiedn); return 0; p=p-next; printf(Sorry! No num has foundn); int out_select() char s_num12; struct out_book * p; p=ohead; printf(Iuput the select numn); scanf(%s,&s_num); while(p!=

34、NULL) if (strcmp(s_num,p-num)=0) printf(The data you want is:n); printf( %s %s %s %d %d %dn, p-num,p-p_num,p-name,p-amount,p-price,p-t_price); return 0; p=p-next; printf(Sorry! No num has foundn); int out_delete() char d_num12; struct out_book * p1,* p; p=ohead; printf(Iuput the delete numn); scanf(

35、%s,&d_num); if (p=NULL)/*开始没有数据*/ 沈 阳 大 学课程设计说明书 NO. 20printf(No data can be foundn); return 0; if (strcmp(p-num,d_num)=0 & p-next=NULL)/*链表只有一个数据,且是要删除的*/ ohead=NULL; printf(One data has been deletedn); return 0; if (strcmp(p-num,d_num)=0 & p-next!=NULL)/*要删除的数据在链表的头上*/ ohead=ohead-next; printf(One data has been deletedn); return 0; while(p-next!=NULL) p1=p-next; if (strcmp(p1-num,d_num)=0) p-next=p1-next; printf(One data has been deletedn); return 0; p=p-next; printf(Sorry!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1