您好,欢迎来到筏尚旅游网。
搜索
您的当前位置:首页入库模块报告书

入库模块报告书

来源:筏尚旅游网


《数据结构大型实验》

学生姓名:学 院:专 业:实验题目:完成时间:指导教师:

1 实验报告

班 级: 信息与通信工程学院 通信工程专业

仓库物资管理 2009-9-11 杨顺民、 辛洁

一,需求分析:

作为一个仓库管理系统软件,要求能实现四类库存货品(黑色金属、有色金属、非金属、机械制品)信息的入库、出库、查找、统计等功能,并能够将建立和更新的库存信息保存于文件以供输出或打印。我们首先规定了货品的相关信息包括:账号、规格、品名、数量、单价、金额,出入库日期等,之后我们通过键盘输入货物的相关信息。

对于查找程序,我们要求程序可以通过账号进行查询。对于统计程序,我们要求程序可以显示仓库货物的数量和价格并按月、季、年分别输出四大类物资的报表。整个程序运行时,我们只需按屏幕上的提示进行自己需要的操作就行了。 输入数据类型:整型,字符型; 输入数据的取值范围: 0至12; 输出数据类型:整型,字符型;

二,概要设计:

1.方案确定:

库存货品信息管理系统要求实现许多功能,可遵循结构化程序设计思想来进行本系统的设计,通过小组讨论,我们决定采用线性链表的结构来储存货物信息。并把整个系统分为五个模块:入库模块,出库模块,查询模块,统计模块和主函数模块。运行时,通过主函数的调用来实现所需的功能。

其中本程序中用到的抽象数据类型的定义有:线性链表结构体的定义;创建链表的头节点以及在进行入库时货物存储即链表的插入,出库时链表的删除等;头节点声明,以及函数调用时的声明等。 2.具体结构:

库存货品信息管理系统的软件具体结构如图:

主程序模块 入库模块 出库模块 查询模块 统计模块 对 对黑有色色 金金属属 的的插插 入入、、 删删除 除

2

对非金属的插入、删除 对机械制品的插入、删除 对黑色金属的修改 对有色金属的修改 对非金属的修改 对机械制品的修改 对黑色金属信息的查询 对有色金属信息的查询 对非金属信息的查询 对机械制品信息的查询 库存物品信息的月报表库存物品信息的季报表 库存物品信息的年报表

3.块功能说明:

对本系统的功能进行分析后可作如下的模块化设计:

入库模块实现功能:能把货品信息按四大类逐一输入,并对其进行插入,删除 出库模块实现功能:能把已经出库的物资从四类链表中插入,删除, 查询模块实现功能:用户可以通过帐号查找相应的货品的信息。

统计模块实现功能:程序可以显示仓库货物表和按月、季、年输出报表。 主程序模块实现功能:完成主菜单的显示,及对各模块的调用。

三,详细设计

1、方案确定

在这次的程序设计中,我负责的是入库模块,根据题目要求,我决定建立四张链表,分别存储黑色、有色、非金属及机械制,所编程序能够分别在是个链表中实的插入和修和修改。运行时通过主函数调用函数来实现插入和修改的功能。

其中本程序中用到的抽象数据类型的定义有:线性链表结构体的定义;创建链表的头节点以及在进行入库时货物存储即链表的插入,入库时链表的插入和删除等;头节点声明,以及函数调用时的声明等。

2.具体结构:

入库具体流程图

开始 入库模块

黑色金属的插入、删除 有色金属的插入、删除 非金属的插入、删除 机械制品的插入、删除 3

1、结构体定义: 黑色金属结构体:

struct heise_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

struct heise_product *next; };

struct heise_product *hhead; 有色金属结构体:

struct youse_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

struct youse_product *next; };

struct youse_product *yhead; 非金属结构体:

struct fei_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price;

4

int year; int season; int month; int day;

struct fei_product *next; };

struct fei_product *fhead; 机械制品结构体:

struct jixie_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

struct jixie_product *next; };

struct jixie_product *jhead;

2、入库产品的插入、删除:

本次试验的入库部分涉及到了黑色金属、有色金属、非金属及机械制品的插入和删除,。 在此仅写出一类金属的插入、删除,其他种类类似。 黑色金属的插入 int heise_insert() {

struct heise_product * p1,* p; /*先定义两个指针*/

p1=(struct heise_product *)malloc(sizeof(struct heise_product)); /*p1申请了空间*/ p=hhead; /*头指针附给p*/

if (p==NULL)/*开始没有数据*/ {

printf(\"Enter the data of heise product\\n\");

printf(\"Include the num,p_num,name,amount,price,total_price,date\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price,&p1->date); /*输入黑色金属信息*/ hhead=p1;

hhead->next=NULL; }

5

while(p->next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p->next; p->next=p1;

printf(\"Enter the data\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price); p1->next=NULL; return 0; }

黑色金属的删除 int heise_delete() {

char d_num[12];

struct heiseproduct * p1,* p; p=hhead;

printf(\"Enter the delete num\\n\");

scanf(\"%s\ /*输入删除的编号*/

if (p==NULL) /*开始没有数据*/ {

printf(\"No data can be found\\n\"); }

if (strcmp(p->num,d_num)==0 && p->next==NULL) /*链表只有一个数据,且是要删除的*/ {

hhead=NULL;

printf(\"One data has been deleted\\n\"); }

if (strcmp(p->num,d_num)==0 && p->next!=NULL) /*要删除的数据在链表的头上*/ {

hhead=hhead->next;

printf(\"One data has been deleted\\n\"); }

while(p->next!=NULL) {

p1=p->next;

if (strcmp(p1->num,d_num)==0) {

p->next=p1->next;

printf(\"One data has been deleted\\n\"); }

p=p->next;

6

}

printf(\"Sorry! No num has found\\n\"); return 0;

四、程序设计与程序调试

1、入库模块的插入与删除:

根据要求,该程序对表格应具有插入、删除的功能,我们经小组讨论决定用线性链表,以方便产品的插入和删除。我们将根据题的要求建立以黑色金属、有色金属、非金属、机械制品为表头的四张链表,然后分别对其进行插入和删除。

2、程序的调试:

由于整个过程都是我们自己编译的,在调试过程中出现不少问题,如函数无返回值、有些指针定义不明确等语法的错误。由于程序复杂,定义链表过多,导致链表冲突,以至于程序无法实现插入循环,在入库模块就出现了循环终止现象,使得整个程序无法正常运行。但因时间有限,还有很多问题没有解决,但在以后我们小组会继续讨论,逐一解决。

五、测试结果

入库部分按如图提醒进行插入、删除后,即可得所需链表

7

整体程序的调试过程如图,按图示提醒诸如即可的相应链表

六,经验总结

本次实验历时两周,对我们来说,确实是做过的最大最耗费时间的一次实验。

拿到题目后,我们首先小组讨论,确定大致思路,根据思路决定所用数据结构和部分主要函数,经讨论我们决定用链表来完成该程序。然后,我们开始分模块进行,大家态度认真,准备积极。可是所编程序在刚开始遇到了问题,当我们拿着各自的模块上机运行时,程序就有不少错误,经过多次的上机调试和修改,模块程序程序基本可以运行,但在各个模块综合成主模块时,我们的程序再次运行错误。之后我们经过查资料,小组讨论,反复检查,又多次的调试与修改,积极地向老师请教,总程序基本可运行。但是功能并不是很强大。

整个实验,让我对c语言有了一次温习,并学到了很多新的东西,对c语言有了更好的掌握,同时也感到个人力量的薄弱,团队精神的重要,在制报表的过程中更感到了自己知识的局限性。以后一定要认真学习,勤于思考,广泛阅读,时常温故,以达到基础稳固,思路开阔。

七、附录

入库模块程序设计如下:

struct heise_product /*黑色物品线形链表的结构体定义*/

8

{

char num[12]; /*黑色物品帐号的定义*/ char p_num[12]; /*黑色物品规格的定义*/ char name[12]; /*黑色物品名称的定义*/ int amount; /*数量的定义*/ int price; /*单价的定义*/ int t_price; /*总价的定义*/ int year; /*年份*/ int season; /*季节*/ int month; /*月份*/ int day; /*日期*/

struct heise_product *next; /*};

struct heise_product *hhead; /*

有色金属结构体:

struct youse_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

struct youse_product *next; };

struct youse_product *yhead; 非金属结构体:

struct fei_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

9 黑色物品指针的定义*/ 为产品建立一个头指针*/

struct fei_product *next; };

struct fei_product *fhead; 机械制品结构体:

struct jixie_product {

char num[12]; char p_num[12]; char name[12]; int amount; int price; int t_price; int year; int season; int month; int day;

struct jixie_product *next; };

struct jixie_product *jhead; int heise_insert() {

struct heise_product * p1,* p; /*先定义两个指针*/

p1=(struct heise_product *)malloc(sizeof(struct heise_product)); /*p1申请了空间*/ p=hhead; /*头指针附给p*/

if (p==NULL)/*开始没有数据*/ {

printf(\"Enter the data of heise product\\n\");

printf(\"Include the num,p_num,name,amount,price,total_price,date\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price,&p1->date); 输入黑色金属信息*/ hhead=p1;

hhead->next=NULL; return 0; }

while(p->next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p->next; p->next=p1;

printf(\"Enter the data\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price); p1->next=NULL; }

10

/*

int youse_insert() {

struct youse_product * p1,* p; /*先定义两个指针*/

p1=(struct youse_product *)malloc(sizeof(struct youse_product)); /*p1申请了空间*/ p=yhead; /*头指针附给p*/

if (p==NULL)/*开始没有数据*/ {

printf(\"Enter the data of youse product\\n\");

printf(\"Include the num,p_num,name,amount,price,total_price,date\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price,&p1->date); 输入有色金属信息*/ yhead=p1;

yhead->next=NULL; return 0; }

while(p->next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p->next; p->next=p1;

printf(\"Enter the data\\n\"); 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 fei_insert() {

struct fei_product * p1,* p; /*先定义两个指针*/

p1=(struct fei_product *)malloc(sizeof(struct fei_product)); /*p1申请了空间*/ p=fhead; /*头指针附给p*/

if (p==NULL)/*开始没有数据*/ {

printf(\"Enter the data of fei product\\n\");

printf(\"Include the num,p_num,name,amount,price,total_price,date\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price,&p1->date); 输入非金属信息*/ fhead=p1;

fhead->next=NULL; return 0; }

while(p->next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p->next; p->next=p1;

printf(\"Enter the data\\n\");

11

/*/*

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 jixie_insert() {

struct jixie_product * p1,* p; /*先定义两个指针*/

p1=(struct jixie_product *)malloc(sizeof(struct jixie_product)); /*p1申请了空间*/ p=jhead; /*头指针附给p*/

if (p==NULL)/*开始没有数据*/ {

printf(\"Enter the data of jixie product\\n\");

printf(\"Include the num,p_num,name,amount,price,total_price,date\\n\"); scanf(\"%s%s%s%d%d%d\

&p1->num,&p1->p_num,&p1->name,&p1->amount,&p1->price,&p1->t_price,&p1->date); /*输入机械制品信息*/ jhead=p1;

jhead->next=NULL; return 0; }

while(p->next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p->next; p->next=p1;

printf(\"Enter the data\\n\"); 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 heise_delete() {

char d_num[12];

struct heiseproduct * p1,* p; p=hhead;

printf(\"Enter the delete num\\n\");

scanf(\"%s\/*输入删除的编号*/ if (p==NULL) /*开始没有数据*/ {

printf(\"No data can be found\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next==NULL) /*链表只有一个数据,且是要删除的*/ {

hhead=NULL;

printf(\"One data has been deleted\\n\");

12

return 0; }

if (strcmp(p->num,d_num)==0 && p->next!=NULL) /*要删除的数据在链表的头上*/ {

hhead=hhead->next;

printf(\"One data has been deleted\\n\"); 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 deleted\\n\"); return 0; }

p=p->next; }

printf(\"Sorry! No num has found\\n\"); }

int youse_delete() {

char d_num[12];

struct youseproduct * p1,* p; p=yhead;

printf(\"Enter the delete num\\n\"); scanf(\"%s\if (p==NULL) {

printf(\"No data can be found\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next==NULL) {

yhead=NULL;

printf(\"One data has been deleted\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next!=NULL) {

yhead=yhead->next;

printf(\"One data has been deleted\\n\");

13

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 deleted\\n\"); return 0; }

p=p->next; }

printf(\"Sorry! No num has found\\n\"); }

int fei_delete() {

char d_num[12];

struct feiproduct * p1,* p; p=fhead;

printf(\"Enter the delete num\\n\"); scanf(\"%s\if (p==NULL) {

printf(\"No data can be found\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next==NULL) {

fhead=NULL;

printf(\"One data has been deleted\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next!=NULL) {

fhead=fhead->next;

printf(\"One data has been deleted\\n\"); return 0; }

while(p->next!=NULL) {

p1=p->next;

if (strcmp(p1->num,d_num)==0) {

14

p->next=p1->next;

printf(\"One data has been deleted\\n\"); return 0; }

p=p->next; }

printf(\"Sorry! No num has found\\n\"); }

int jixie_delete() {

char d_num[12];

struct jixie_product * p1,* p; p=jhead;

printf(\"Enter the delete num\\n\"); scanf(\"%s\if (p==NULL) {

printf(\"No data can be found\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next==NULL) {

jhead=NULL;

printf(\"One data has been deleted\\n\"); return 0; }

if (strcmp(p->num,d_num)==0 && p->next!=NULL) {

jhead=jhead->next;

printf(\"One data has been deleted\\n\"); 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 deleted\\n\"); return 0; }

p=p->next; }

15

printf(\"Sorry! No num has found\\n\"); }

在运行中,也出现了许多的问题,但通过不断的修改和调试,最后基本算能成功的运行

16

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- efsc.cn 版权所有 赣ICP备2024042792号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务