1、数据结构课程设计报告课程设计题目: 产品进销存管理系统 姓 名: 学 号: 指 导 教 师: 完 成 时 间: 数据结构课程设计成绩评定序号评 定 项 目分值得分1选题合理、目的明确102设计方案正确,具有可行性、创新性203程序运行结果正确204态度认真、学习刻苦、遵守纪律155设计报告的规范化、参考文献充分(不少于5篇)106答辩:思路清晰,语言表达准确,概念清楚、正确25最后得分指导老师(签名)日期 年 月 日 目 录(参考)1 系统分析11.1 课程设计内容21.2 系统功能需求分析31.3 数据结构设计42 系统设计52.1 总体设计52.2 各功能模块的设计62.2.162.2.2
2、72.2.382.2.492.2.5102.2.6112.2.7122.2.8132.2.9143 系统调试154 总结205 参考文献22附录(源代码)1 系统分析1.1 课程设计内容设计一个产品进销存管理系统系统的功能包括:1、采用十字链表的存储结构对库房的货品及其数量进行分类管理;2、可以进行产品类的添加,产品进销的添加,产品销货的添加;3、能够查询库房每种产品的进货总数量,销出总数量,产品剩余总数量1.2 系统功能需求分析对其进行库房产品进销存管理,选择线性顺序表来存储产品类,选择线性链表存储产品进销信息,并链接到相应的产品类上。其中存储信息时还应将属于此产品的一些信息如产品的进货或销
3、货总量,进货或销货日期,等进行相应存储。1.3 数据结构设计定义数据Date(日期):int year(年), int month,(月) int day(日)定义数据productlnode(产品信息): int quantity(数量),Date date(日期),productlnode *nextproduct(头指针)定义表sqmountlink:*kindelem,char pkindname,int countName countName count. .Quantity dateQuantity date Quantity dateQuantity date 2 系统设计Mai
4、n()添加产品类(kindInsert)添加进货信息ProQuantity_add添加销货信息ProQuantity_sub查询产品信息visit释放表空间退出DestroyMountList初始化创建表2.1 总体设计开始Int order,I Char a30InitMountList(L1);CreatMountList(L1,0);InitMountList(L2);CreatMountList(L2,1);menu_operation();Switch(order)kindInsert(L1,i)DisplayList(L1)ProQuantity_add(L1,a,q);Displ
5、ayList(L1);ProQuantity_sub(L2,a,q);DisplayList(L2);Visit(L1,L2,a);DestroyMountList(L1);DestroyMountList(L2);输入命令:exit(0)结束2.2 各功能模块的设计2.2.1 主函数main() 2.2.2 初始化函数模块开始给L.kindelem分配内存!L.kindelemexit(overflow)L.length =0L.listsize =100i=0icount=0;i+return ok结束否是是否printf(输入此产品进货次数:n)输入产品进货数量及日期L.kindelem
6、 -count=p-quantity;L.kindelemi.firstproduct =p;p-nextproduct =NULL;scanf(%d,&k)开始plinklist p,qint i,j,n,k,m;printf(此线性表L中含有的产品类个数:n)i=0i=1给指针p分配内存j=1jnextproduct =p-nextproduct ;p-nextproduct =q;p=q;j+printf(输入此产品销货次数:n)scanf(%d,&m);m=1给指针p分配内存输入产品销货数量及日期L.kindelem -count=p-quantity;L.kindelemi.firs
7、tproduct =p;p-nextproduct =NULLj=1jcount+=q-quantity;q-nextproduct =p-nextproduct ;p=q;j+L.length+结束2.2.3 创建表函数模块是否否是是否开始int iplinklist pprintf(名称 日期 数量n)i=0inextproducti+结束2.2.4 显示表结构函数模块否是否是否是是否开始int i;kindlnode *p; plinklist q;i=L.lengthi=0p=&(L.kindelem i)(*p).firstproduct =NULLfree(p);(*p).firs
8、tproduct!=NULLq=(*p).firstproductq-nextproduct!=NULLfree(q);q=q-nextproductfree(p)结束i-2.2.5销毁表单函数模块3 系统调试4 总 结1.巩固和加深了对数据结构的理解,提高综合运用本课程所学知识的能力2.培养了我选用参考书,查阅手册及文献资料的能力。培养独立思考,深入研究,分析问题,解决问题的能力。3通过实际编译系统的分析设计,变成调试,掌握应用软件的分析方法和工程设计方法4.通过课程设计,培养了我严肃认证的学习作风,逐步建立正确的生产观念,经济观念和全局观念。5 参考文献 1 尹康,石教英,潘志庚一种鲁棒性
9、好的图像水印算法J软件学报,2001,12(5):668-676 2 严蔚敏,吴伟民.数据结构. M清华大学出版社,2005.(参考上述两篇的格式)附 录 #include#include#include#define ok 1#define error 0#define overflow 0#define SQMOUNTLINK_INIT_SIZE 100#define SQMOUNTLINKCREMENT 10typedef struct Dateint year;int month;int day;Date;typedef struct productlnode int quantity
10、;Date date;struct productlnode *nextproduct;productlnode,*plinklist;typedef struct kindlnode productlnode *firstproduct;char pkindname30;int count;kindlnode;typedef struct kindlnode *kindelem;int length;int listsize;int key;sqmountlink;int InitMountList(sqmountlink &L) int i;L.kindelem=(kindlnode*)m
11、alloc(SQMOUNTLINK_INIT_SIZE*sizeof(kindlnode);if(!L.kindelem )exit(overflow);L.length =0;L.listsize =SQMOUNTLINK_INIT_SIZE;for(i=0;iL.listsize ;i+) (L.kindelem i).firstproduct =NULL;L.kindelemi.count=0;return ok;int CreatMountList(sqmountlink &L,int key) plinklist p,q;int i,j,n,k,m;printf(此线性表L中含有的产
12、品类个数:n);scanf(%d,&n);for(i=0;i=1) p=(plinklist)malloc(sizeof(productlnode); printf(输入此产品类的进货数量、进货日期:n); scanf(%d%d,%d,%d,&(p-quantity),&(p-date ).year ), &(p-date ).month ),&(p-date ).day ); L.kindelemi.count=p-quantity; L.kindelemi.firstproduct =p; p-nextproduct =NULL; for(j=1;jquantity),&(q-date )
13、.year ),&(q-date ).month ),&(q-date ).day );L.kindelemi.count+=q-quantity; q-nextproduct =p-nextproduct ; p-nextproduct =q; p=q; else printf(输入此产品销货次数:n); scanf(%d,&m); if(m=1) p=(plinklist)malloc(sizeof(productlnode); printf(输入此产品类的销货数量、销货日期:n); scanf(%d%d,%d,%d,&(p-quantity),&(p-date ).year ),&(p-
14、date ).month ),&(p-date ).day ); L.kindelem i.count=p-quantity; L.kindelemi.firstproduct =p; p-nextproduct =NULL; for(j=1;jquantity),&(q-date ).year ),&(q-date ).month ),&(q-date ).day ); L.kindelemi.count+=q-quantity; q-nextproduct =p-nextproduct ; p-nextproduct =q; p=q; L.length+;return ok;int Kin
15、dInsert(sqmountlink &L,int n) int i;kindlnode *newbase;if(L.length+n=L.listsize ) newbase=(kindlnode *)realloc(L.kindelem,(L.listsize +n)*sizeof(kindlnode);if(!newbase)exit(overflow);L.kindelem =newbase;L.listsize +=n;printf(需添加的产品类名称:n); for(i=0;in;i+) scanf(%s,&L.kindelemL.length.pkindname );L.kin
16、delem L.length .firstproduct =NULL;L.length +;return ok;void ProQuantity_add(sqmountlink &L1,char pkindname1,plinklist q)int i;plinklist p;for(i=0;iL1.length ;i+) if(strcmp(L1.kindelem i).pkindname ,pkindname1)!=0)continue;elsebreak;if(inextproduct =NULL;else p=L1.kindelemi.firstproduct;while(p-next
17、product!=NULL)p=p-nextproduct;p-nextproduct=q;q-nextproduct=NULL;L1.kindelemi.count+=q-quantity;void ProQuantity_sub(sqmountlink &L2,char pkindname2,plinklist s) int i;plinklist p;for(i=0;iL2.length ;i+)if(strcmp(L2.kindelem i).pkindname ,pkindname2)!=0)continue;elsebreak;if(inextproduct =NULL;else
18、p=L2.kindelemi.firstproduct;while(p-nextproduct !=NULL)p=p-nextproduct;p-nextproduct =s;s-nextproduct =NULL;L2.kindelemi.count+=s-quantity;void Visit(sqmountlink &L1,sqmountlink &L2,char pkindname3)int i,j;for(i=0;iL1.length ;i+)if(strcmp(L1.kindelem i).pkindname ,pkindname3)=0) break; for(j=0;jL2.l
19、ength ;j+)if(strcmp(L2.kindelem j).pkindname ,pkindname3)=0) break; if(iL1.length&jL2.length )printf(输出产品%s的总数量:%dn,pkindname3,(L1.kindelemi.count)-(L2.kindelemj.count);void DisplayList(sqmountlink &L)int i;plinklist p;printf(名称 日期 数量n);for(i=0;inextproduct ) printf(%s %d,%d,%d %d, L.kindelemi.pkind
20、name , (p-date ).year , (p-date ).month , (p-date ).day , p-quantity ); printf(n);void DestroyMountList(sqmountlink &L)int i;kindlnode *p;plinklist q;for(i=L.length ;i=0;i-)p=&(L.kindelem i);if(*p).firstproduct =NULL)free(p);elsewhile(*p).firstproduct)for(q=(*p).firstproduct ;q-nextproduct ;q=q-next
21、product );free(q);free(p);void menu_operation()printf(-输入所要执行操作:-n);printf(-产品类的添加:1-n);printf(-产品进货:2-n);printf(-产品销货:3-n);printf(-查询每种产品所属产品类的总数量:4-n);printf(-释放L所占内存空间,退出程序:0-n);void main(void)int order;int i;char a30;plinklist q=(plinklist)malloc(sizeof(productlnode);sqmountlink L1,L2;printf(-创建
22、初始的产品进货表L1-n);InitMountList(L1);CreatMountList(L1,0);printf(-创建初始的产品销货表L2-n);InitMountList(L2);CreatMountList(L2,1);printf(-初始的产品进货表和销货表创建完成-n);menu_operation();loop:printf(输入命令:);scanf(%d,&order);switch(order)case 1:printf(需添加产品类的个数:);scanf(%d,&i);KindInsert(L1,i);printf(输出修改后的产品库存管理表:n);DisplayLis
23、t(L1);goto loop;case 2:printf(需添加产品所属产品类的名称:);scanf(%s,&a);printf(需向此产品类添加产品的个数和日期:);scanf(%d%d,%d,%d,&(q-quantity),&(q-date ).year ),&(q-date ).month ),&(q-date ).day );ProQuantity_add(L1,a,q);printf(输出修改后的产品库存管理表:n);DisplayList(L1);goto loop;case 3:printf(输入需销出所属产品类的名称:);scanf(%s,&a);printf(输入需销出产品的数量和日期:); scanf(%d %d,%d,%d,&(q-quantity),&(q-date ).year ),&(q-date ).month ),&(q-date ).day );ProQuantity_sub(L2,a,q);printf(输出修改后的产品库存管理表:n);DisplayList(L2);goto loop;case 4:printf(输入待查询产品所属产品类的名称:);scanf(%s,&a);Visit(L1,L2,a);goto loop;case 0:DestroyMountList(L1);DestroyMountList(L2);exit(0);