C语言程序课程设计商品进销存管理程序Word下载.docx
- 文档编号:3356521
- 上传时间:2023-05-01
- 格式:DOCX
- 页数:35
- 大小:339.39KB
C语言程序课程设计商品进销存管理程序Word下载.docx
《C语言程序课程设计商品进销存管理程序Word下载.docx》由会员分享,可在线阅读,更多相关《C语言程序课程设计商品进销存管理程序Word下载.docx(35页珍藏版)》请在冰点文库上搜索。
floatjiage;
structgoods*next;
};
intn,k;
structgoods*head;
等一些变量。
(2)数据输入的形式和输入值的范围
字符不超过20位
整型变量输入大于0
浮点型变量也大于0
商品编号为四位整数
(3)数据输入的形式
按程序运行的提示操作※
(4)程序所能达到的功能及出错处理
该程序具有以下功能:
二程序设计思路
根据要求首先设计一个结构体类型,设计好界面,设计好主函数。
程序各功能通过调用子函数来实现
用switch来实现菜单的选择
一切数据信息通通存在文件中,并实现文件读写操作。
设计子函数来实现查询,保存,读取数据,删除等操作。
【总体设计】
图1系统功能模块图
【详细设计】
1.主函数
主函数设计要求简洁,只提供部分提示语和函数的调用
【程序】
图2.主函数流程图
具体设计如下:
结构体设计
主函数设计
voidmain()
{
voidjieman();
voidluru();
structgoods*shuju();
voidshanchu(structgoods*head);
voidjinghuo(structgoods*head);
voidxiaoshu(structgoods*head);
voidxiugai(structgoods*head);
voidchaxun(structgoods*head);
structgoods*head=NULL;
intk=0;
system("
cls"
);
jieman();
printf("
请选择你要的功能键:
"
scanf("
%d"
&
k);
getchar();
while(k!
=0)
{
head=shuju();
switch(k)
{case1:
luru();
break;
case2:
xiugai(head);
case3:
chaxun(head);
case4:
xiaoshu(head);
case5:
jinghuo(head);
case6:
shanchu(head);
case0:
exit(0);
default:
printf("
pleasetryagain!
\n"
}
}
界面设计
voidjieman()
********************************************\n"
☆☆☆★★★欢迎进入商品管理系统★★★☆☆☆\n"
**1*录入信息☆☆***************★★★☆☆☆\n"
**2*修改信息☆☆***************★★★☆☆☆\n"
**3*查询信息☆☆***************★★★☆☆☆\n"
**4*销售信息☆☆***************★★★☆☆☆\n"
**5*进货信息☆☆***************★★★☆☆☆\n"
**6*删除信息☆☆***************★★★☆☆☆\n"
**0*退出系统☆☆***************★★★☆☆☆\n"
文件保存函数设计
structgoods*baocun(structgoods*head)
structgoods*p=NULL;
FILE*fp=NULL;
charch='
\0'
;
getchar();
是否保存到文件(y/n):
ch=getchar();
putchar(10);
if(ch=='
y'
||ch=='
Y'
)
fp=fopen("
"
wb"
p=head;
if((fp==NULL)&
&
(p==NULL))
读取数据失败!
exit(0);
while(p!
=NULL)
fprintf(fp,"
%d\n%s\n%d\n%f\t"
p->
number,p->
name,p->
shumu,p->
jiage);
p=p->
next;
保存成功!
fclose(fp);
return(head);
elseif(ch=='
n'
N'
信息未保存到文件!
else
sorry,pleasetryagain(y/n):
数据读取函数设计
structgoods*shuju()
intn=0;
FILE*fp;
structgoods*head=NULL,*p1,*p2;
rb"
if(fp==NULL)
\nsorry,读取数据失败!
p1=p2=(structgoods*)malloc(LEN);
fscanf(fp,"
%d%s%d%f"
p1->
number,p1->
name,&
shumu,&
while(!
feof(fp))
n++;
if(n==1)head=p1;
elsep2->
next=p1;
p2=p1;
p1=(structgoods*)malloc(LEN);
p2->
next=NULL;
录入函数设计
voidluru()
{structgoods*shuju();
structgoods*baocun(structgoods*head);
structgoods*p1,*p2,*p3;
head=shuju();
p1=head;
p2=(structgoods*)malloc(LEN);
请输入四位编号:
scanf("
p2->
number);
请输入商品名:
%s"
p2->
name);
请输入商品数量:
shumu);
请输入商品价格:
%f"
if(p1==NULL)
{p1=p2;
baocun(p2);
return;
while(p1!
{p3=p1;
p1=p1->
p3->
next=p2;
baocun(head);
进货函数设计
voidjinghuo(structgoods*head)
{structgoods*baocun(structgoods*head);
intc;
intp;
structgoods*p1,*p2;
p);
p1=head;
=p1->
number&
next!
p1=p1->
if(p==p1->
number)
\n商品编号\t商品名\t数量\t价格\n"
%d\t\t%s\t\t%d\t\t%f\n"
p1->
name,p1->
shumu,p1->
请输入该商品经货个数:
c);
p1->
shumu=p1->
shumu+c;
该商品经货个数:
%d\n"
baocun(head);
删除函数设计
voidshanchu(structgoods*head)
{structgoods*p1,*p2;
intp;
system("
while(p!
{p2=p1;
if(p==p1->
{printf("
\n商品编号\t商品名\t数量\t价格\n"
%d\t\t%s\t\t%d\t\t%.2f\n"
if(p1==head)head=p1->
elsep2->
next=p1->
n=n-1;
删除成功!
查询函数设计
voidchaxun(structgoods*head)
inta,c,i=0;
chart[20];
1*商品编号查询\n"
2*商品名字查询\n"
请选择你需要的功能键\n"
a);
if(a==1)
while(c!
=0&
i==0)
{p2=p1;
if(c==p1->
{printf("
\n商品编号\t名字\t数目\t价格:
%d\t%s\t%d\t%.2f\n"
i=1;
else{printf("
系统中无该商品记录!
pressenterreturn!
if(a==2&
请输入商品名字:
t);
while(strcmp(t,"
0"
)!
if(strcmp(t,p1->
name)!
name)==0)
%d\t%s\t%d\t%f\n"
else{printf("
修改函数设计
voidxiugai(structgoods*head)
intp,i=0;
if(p!
请输入要修改的新商品编号"
i=1;
if(i==1)
修改后新商品编号名字数目价格:
%d%s%d%f"
修改成功!
销售函数设计
voidxiaoshu(structgoods*head)
请输入该商品售货个数:
shumu-c;
三程序清单
#include<
>
#defineLENsizeof(structgoods)
structgoods结构体
商品编号
商品名
商品数目
商品价格
全局变量
voidmain()主函数
界面函数声明
录入函数声明
数据读取函数声明
删除函数声明
进货函数声明
销售函数声明
修改函数声明
查询函数声明
structgoods*baocun(structgoods*head)保存函数
判断是否保存
=NULL)
voidchaxun(structgoods*head)查询函数
=NULL)查找商品
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 程序 课程设计 商品 进销存 管理程序