C语言小型物流仓储管理系统课程设计Word文档下载推荐.docx
- 文档编号:19530994
- 上传时间:2023-01-07
- 格式:DOCX
- 页数:22
- 大小:21.46KB
C语言小型物流仓储管理系统课程设计Word文档下载推荐.docx
《C语言小型物流仓储管理系统课程设计Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C语言小型物流仓储管理系统课程设计Word文档下载推荐.docx(22页珍藏版)》请在冰豆网上搜索。
输入要查找的物资名称,系统会自动显示对应的物资信息。
最后就是退出程序
4.程序详细设计
程序共有20个函数,分别为
voidCreatStock()
voidCreatInstock()
voidCreatoutstock()
voidSearchElename();
voidSearchBrand();
voidSearchDate();
voidSearchElenameAndBrand();
voidPrintStock(structstock*p);
voidPrintInstock(structinstock*p);
voidPrintOutstock(structoutstock*p)
voidSearchMenu()
voidCountMenu()
voidCount4()
voidmain()
intread_stock()
intread_instock()
intread_outstock()
intCount1()
intCount2()
intCount3()
其中程序末尾定义了main函数,主函数voidmain(),主要通过调用各个成员函数,最终实现物资信息的创建、查找、统计等各项功能。
5.课程设计心得与体会
在这次C语言课程设计中,我收获颇丰也发现了自己许多不足的地方,结合自己所学并通过查阅资料,在程序设计过程中加深了我对面向对象的程序设计方法的认识,在巩固了基本的程序设计方法的基础上进一步学习了C中类的定义、成员方法的使用以及函数的调用
等。
同时,在程序的设计过程中暴露出了许多问题,首先,程序设计之初思路混乱,面对程序要求的各项功能如:
教师信息的创建、删除、修改、查找等无从下手,最终通过一个个的子函数分别完成不同的功能并通过主函数调用最终实现程序功能的完整性;
第二,平时对于面向对象的程序设计方法仅仅局限于概念上的理解,真正实现起来被每个对象繁杂的属性搞的晕头转向;
第三,自己对C语言的学习仅仅局限于课本知识,很少实践,以至于在编程过程中错误不断甚至出现低级的语法错误。
这次课程设计使我的编程能力得到了很大的提高,加深了我对面向对象这一概念的理解,对以后其他面向对象程序语言的学习打好良好基础,同样也在编程方面积累了经验
6.参考资料
《C程序设计》
7.程序源代码
#include"
stdio.h"
#include<
stdlib.h>
string.h>
conio.h>
#defineSTOCKNUM3//原来库存中家电的种类
#defineINSTOCKNUM3//每次输入的家电种类
#defineOUTSTOCKNUM3//出库家电的种类
structdate//时间结构
{
intyear;
intmonth;
intday;
};
structstock//库存结构
charelename[20];
charbrand[20];
chartype[20];
intstocknum;
;
intvalue;
}stoc[STOCKNUM+INSTOCKNU;
structinstock//入库结构;
charelename[20];
charbrand[20];
chartype[20];
intinstocknum;
intprice;
structdateintime;
charsendername[20];
}in
intstocknum;
intvalue;
}stoc[STOCKNUM+INSTOCKNUM];
structinstock//入库结构
intinstocknum;
intprice;
structdateintime;
charsendername[20];
}in[INSTOCKNUM];
structoutstock//出库结构
intoutstocknum;
structdateouttime;
chardelivername[20];
}out[OUTSTOCKNUM];
//-------------------------------------------------------------------------
voidCreatStock()//创建库存记录文件
inti;
FILE*fp;
if((fp=fopen("
stock.txt"
"
w"
))==NULL)
printf("
Can'
topenfile!
\n"
);
exit(0);
}
for(i=0;
i<
STOCKNUM;
i++)
请输入电器的信息!
\n电器名称品牌名称型号库存数量价值\n"
scanf("
%s%s%s%d%d"
stoc[i].elename,stoc[i].brand,stoc[i].type,&
stoc[i].stocknum,&
stoc[i].value);
fwrite(&
stoc[i],sizeof(structstock),1,fp);
fclose(fp);
//-----------------------------------------------------------------------------
intread_stock()//读取库存文件到stoc[]
inti=0;
r"
topenfile:
stock.txt!
return0;
if(fgetc(fp)<
0)//读入的是文件结束符
rewind(fp);
//使位置指针重新移到文件开头
while(!
feof(fp))
fread(&
i++;
return--i;
//返回库存家电的种类
//----------------------------------------------------
intread_instock()//读取入库文件到in[]
instock.txt"
instock.txt!
0)return0;
in[i],sizeof(structinstock),1,fp);
//返回入库家电的种类
//-----------------------------------------------------
intread_outstock()//读取出库文件到out[]
outstock.txt"
outstock.txt!
out[i],sizeof(structoutstock),1,fp);
//返回出库家电的种类
voidCreatInstock()//创建入库记录并改变库存记录
inti,j,k;
intan=STOCKNUM;
intboolean=0;
INSTOCKNUM;
电器名称品牌名称型号入库数量单价入库时间(年月日)送货人姓名\n"
%s%s%s%d%d%d%d%d%s"
in[i].elename,in[i].brand,in[i].type,&
in[i].instocknum,&
in[i].price,&
in[i].intime.year,&
in[i].intime.month,&
in[i].intime.day,in[i].sendername);
printf("
有物资入库!
read_instock();
//读取instock.txt入in[];
read_stock();
//读取stock.txt入stoc[];
for(k=0;
k<
k++)
boolean=0;
for(j=0;
j<
j++)
if(strcmp(stoc[j].elename,in[k].elename)==0&
&
strcmp(stoc[j].brand,in[k].brand)==0&
strcmp(stoc[j].type,in[k].type)==0)
stoc[j].stocknum=stoc[j].stocknum+in[k].instocknum;
boolean=1;
if(boolean==0)//原来库存中没有此类家电
strcpy(stoc[an].elename,in[k].elename);
strcpy(stoc[an].brand,in[k].brand);
strcpy(stoc[an].type,in[k].type);
stoc[an].stocknum=in[k].instocknum;
stoc[an].value=in[k].price;
an++;
fwrite(stoc,sizeof(structstock),an,fp);
//------------------------------------------------------------------------
voidCreatoutstock()//创建出库记录并改变库存记录
inti=0,j=0,k=0,n=0;
intsum_stock=0;
sum_stock=read_stock();
//读取stock.txt入stoc[]
共有家电物资%d种\n"
sum_stock);
for(n=0;
n<
OUTSTOCKNUM;
n++)
电器名称品牌名称型号出库数量出库时间(年月日)
提货人姓名
%s%s%s%d%d%d%d%s"
out[n].elename,out[n].brand,out[n].type,&
out[n].outstocknum,&
out[n].outtime.year,&
out[n].outtime.month,&
out[n].outtime.day,out[n].delivername);
有物资出库!
3;
if((strcmp(stoc[i].elename,out[j].elename)==0)&
(strcmp(stoc[i].brand,out[j].brand)==0)&
(strcmp(stoc[i].type,out[j].type)==0))
k=1;
if(out[j].outstocknum<
=stoc[i].stocknum)
out[j],sizeof(structoutstock),1,fp);
stoc[i].stocknum=stoc[i].stocknum-out[j].outstocknum;
资源%s出库成功!
out[j].elename);
else
if(out[j].outstocknum>
stoc[i].stocknum)
//else
{printf("
\n超出库存量!
\n按任意键继续!
getch();
}}
if(k==0)
\n库存中不存在该信息!
}
fwrite(stoc,sizeof(structstock),sum_stock,fp);
//----------------------;
voidSearchElename();
voidSearchBrand();
voidSearchDate();
voidSearchElenameAndBran;
voidPrintStock(structsto;
voidPrintInstock(structi;
voidPrintOutstock(stru
//--------------------------------------------
voidPrintOutstock(structoutstock*p);
//--------------------------------------------------------------------
voidSearchMenu()//查询菜单
intselect;
while
(1)
\n欢迎使用查询功能!
*****************************************************\n"
输入1按电器名称查询\n"
输入2按品牌名称查询\n"
输入3按日期查询\n"
输入4按电器名称和型号查询\n"
输入0退出查询功能\n"
\n请选择查询方式:
"
%d"
&
select);
getchar();
switch(select)
case1:
SearchElename();
break;
case2:
SearchBrand();
case3:
SearchDate();
case4:
SearchElenameAndBrand();
case0:
return;
default:
\n错误!
请重新选择!
voidSearchElename()//按照电器名称查询
charcelename[20],c='
y'
;
//库存中家电的种类
while(c=='
||c=='
Y'
)
\n请输入电器名称:
%s"
celename);
sum_stock;
if(strcmp(stoc[i].elename,celename)==0)
\n库存电器%d的信息\n"
i);
PrintStock(&
stoc[i]);
\n按任意键继续!
getch();
if(boolean==0)
没有电器:
%s\n"
\n继续查询其他库存信息吗?
)(y/n):
c=getchar();
//--------------------------------------------------------
voidSearchBrand()//按照品牌名称查询
charcbrand[20],c='
\n请输入品牌名称:
cbrand);
if(strcmp(stoc[i].brand,cbrand)==0)
//---------------------------------------------------------
voidSearchDate()//按照日期查询
inti,j;
intsum_instock=0,sum_outstock=0;
intbooleanin=0,booleanout=0;
structdatetime;
sum_instock=read_instock();
sum_outstock=read_outstock();
\n请输入日期:
"
%d%d%d"
time.year,&
time.month,&
time.day);
sum_instock;
if(in[i].intime.year==time.year&
in[i].intime.month==time.monthin[i].intime.day==time.day)
PrintInstock(&
in[i]);
booleanin++;
if(out[j].outtime.year==time.year&
out[j].outtime.month==time.monthout[j].outtime.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 小型 物流 仓储 管理 系统 课程设计