版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 一 题目及运行说明商品进销存管理程序 1、题目描述设计一个商品进销管理程序,该程序具有以下功能:(1) 录入商品信息;(2) 给定商品编号,修改该商品信息;(3) 给定商品编号,删除该商品信息;(4) 录入商品的进货和销售信息;(5) 给定商品编号或商品名,查看该商品及库存信息;(6) 统计功能:提供一些统计各类信息的功能。2、题目要求(1) 按照分析、设计、编码、调试和测试过程完成应用程序;(2) 学习并使用流程图等工具,并在撰写报告中使用;(3) 程序的各项功能在程序运行时,以菜单形式选择并执行;(4) 要求用户输入数据时,要给出清晰、明确的提示,包括:输入数据的内容、格式及其结束方式等
2、(5) 所有的信息存储在一个文件或多个中,并实现文件读写操作。(6) 程序中用链表存放商品及进销存信息并实现增删减功能。3、提示(1) 提醒事件信息可以设计一个结构体类型推荐精选(2) 自己构思并增加的除规定功能之外的新功能,酌情加分。(1) 程序中主要变量Struct goods *head 结构体指针Int n,k struct goodsint number;char name20;int shumu;float jiage;struct goods *next;int n,k;struct goods *head;等一些变量。(2) 数据输入的形式和输入值的范围字符不超过20位整型变量
3、输入大于0浮点型 变量也大于0推荐精选商品编号为四位整数(3) 数据输入的形式按程序运行的提示操作(4) 程序所能达到的功能及出错处理该程序具有以下功能:(1) 录入商品信息;(2) 给定商品编号,修改该商品信息;(3) 给定商品编号,删除该商品信息;(4) 录入商品的进货和销售信息;(5) 给定商品编号或商品名,查看该商品及库存信息;(6) 统计功能:提供一些统计各类信息的功能。二 程序设计思路根据要求首先设计一个结构体类型,设计好界面,设计好主函数。程序各功能通过调用子函数来实现推荐精选用switch来实现菜单的选择一切数据信息通通存在文件中,并实现文件读写操作。设计子函数来实现查询,保存
4、,读取数据,删除等操作。 【总体设计】商品管理系统数据录入数据修改删除商品销售查找进货图1 系统功能模块图 【详细设计】1. 主函数主函数设计要求简洁,只提供部分提示语和函数的调用【程序】推荐精选 显示一系列功能选项输入k,判断k是否是06?根据k的值调用各功能模块函数结束开始k 图2. 主函数流程图具体设计如下:结构体设计struct goodsint number;char name20;int shumu;float jiage;struct goods *next;主函数设计推荐精选void main() void jieman(); void luru(); struct goods
5、 *shuju(); void shanchu(struct goods *head); void jinghuo(struct goods *head); void xiaoshu(struct goods *head); void xiugai(struct goods *head); void chaxun(struct goods *head); struct goods *head=NULL; int k=0; system("cls"); jieman(); printf("请选择你要的功能键:"); scanf("%d"
6、,&k);getchar(); while(k!=0) head=shuju(); switch(k) case 1:luru();break; 推荐精选 case 2:xiugai(head);break; case 3:chaxun(head);break; case 4:xiaoshu(head);break; case 5:jinghuo(head);break; case 6:shanchu(head);break; case 0:exit(0); default:printf("please try again!n"); jieman(); printf
7、("请选择你要的功能键:"); scanf("%d",&k); 界面设计void jieman() printf("*n"); printf("欢迎进入商品管理系统n"); printf("*1 *录入信息*n");推荐精选 printf("*2 *修改信息*n"); printf("*3 *查询信息*n"); printf("*4 *销售信息*n"); printf("*5 *进货信息*n"); print
8、f("*6 *删除信息*n"); printf("*0 *退出系统*n"); printf("欢迎进入商品管理系统n"); printf("*n");文件保存函数设计struct goods *baocun(struct goods *head) struct goods *shuju(); struct goods *p=NULL; FILE *fp=NULL; char ch='0' getchar(); printf("是否保存到文件?(y/n):"); ch=getcha
9、r();推荐精选 putchar(10); if(ch='y'|ch='Y') fp=fopen("goods.txt","wb"); p=head; if(fp=NULL)&&(p=NULL) printf("读取数据失败!"); exit(0); while(p!=NULL) fprintf(fp,"%dn%sn%dn%ft",p->number,p->name,p->shumu,p->jiage); p=p->next; print
10、f("保存成功!n"); fclose(fp); return(head); 推荐精选 else if(ch='n'|ch='N') printf("信息未保存到文件!n"); head=shuju(); return(head); else printf("sorry,please try again(y/n):"); ch=getchar(); putchar(10); return(head);数据读取函数设计struct goods *shuju() int n=0; FILE *fp; str
11、uct goods *head=NULL,*p1,*p2;推荐精选 fp=fopen("goods.txt","rb"); if(fp=NULL) printf("nsorry,读取数据失败!n"); exit(0); else p1=p2=(struct goods *)malloc(LEN); fscanf(fp,"%d%s%d%f",&p1->number,p1->name,&p1->shumu,&p1->jiage); while(!feof(fp) n+;
12、if(n=1)head=p1; else p2->next=p1; p2=p1; p1=(struct goods *)malloc(LEN); fscanf(fp,"%d%s%d%f",&p1->number,p1->name,&p1->shumu,&p1->jiage); p2->next=NULL;推荐精选 fclose(fp); return(head); 录入函数设计void luru()struct goods *shuju();struct goods *baocun(struct goods *he
13、ad);struct goods *p1,*p2,*p3;head=shuju();p1=head;p2=(struct goods *)malloc(LEN);printf("请输入四位编号:");scanf("%d",&p2->number);printf("请输入商品名:");scanf("%s",p2->name);printf("请输入商品数量:");推荐精选scanf("%d",&p2->shumu);printf("请
14、输入商品价格:");scanf("%f",&p2->jiage);if(p1=NULL)p1=p2;p2->next=NULL;baocun(p2);return;while(p1!=NULL)p3=p1;p1=p1->next;p3->next=p2;p2->next=NULL;baocun(head);进货函数设计void jinghuo(struct goods *head)struct goods *baocun(struct goods *head);推荐精选 int c; int p; struct goods *
15、p1,*p2; system("cls"); printf("请输入四位编号:"); scanf("%d",&p); p1=head; while(p!=p1->number&&p1->next!=NULL) p2=p1; p1=p1->next; if(p=p1->number) printf("n 商品编号 t 商品名 t 数量 t 价格 n"); printf("%dtt%stt%dtt%fn",p1->number,p1->na
16、me,p1->shumu,p1->jiage); printf("请输入该商品经货个数:"); scanf("%d",&c); p1->shumu=p1->shumu+c; printf("该商品经货个数:%dn",p1->shumu);推荐精选 baocun(head);删除函数设计void shanchu(struct goods *head)struct goods *p1,*p2;struct goods *baocun(struct goods *head);int p;system(&
17、quot;cls");printf("请输入四位编号:");scanf("%d",&p);p1=head;while(p!=p1->number&&p1->next!=NULL)p2=p1;p1=p1->next;if(p=p1->number)推荐精选printf("n商品编号 t商品名 t 数量 t 价格 n");printf(" %dtt%stt%dtt%.2fn",p1->number,p1->name,p1->shumu,p1-&
18、gt;jiage);if(p1=head) head=p1->next;else p2->next=p1->next;n=n-1; printf("删除成功!n"); baocun(head); 查询函数设计void chaxun(struct goods *head) int a,c,i=0; struct goods *p1,*p2; char t20; printf(" 1*商品编号查询n"); printf(" 2*商品名字查询n"); printf("请选择你需要的功能键n");推荐精选
19、 scanf("%d",&a); getchar(); if(a=1) printf("请输入四位编号:"); scanf("%d",&c);getchar(); while(c!=0&&i=0) p1=head; while(c!=p1->number&&p1->next!=NULL) p2=p1;p1=p1->next; if(c=p1->number) printf("n 商品编号 t 名字 t 数目 t 价格:n"); printf(&
20、quot; %dt %st %dt %.2fn",p1->number,p1->name,p1->shumu,p1->jiage);i=1; else printf("系统中无该商品记录!press enter return!n");getchar();system("cls");return; if(a=2&&i=0)推荐精选 system("cls");printf("请输入商品名字:"); scanf("%s",&t);getcha
21、r(); while(strcmp(t,"0")!=0&&i=0) p1=head; if(strcmp(t,p1->name)!=0&&p1->next!=NULL) p2=p1;p1=p1->next; if(strcmp(t,p1->name)=0) printf("n 商品编号 t 名字 t 数目 t 价格:n"); printf(" %dt %st %dt %fn",p1->number,p1->name,p1->shumu,p1->jiage)
22、;i=1;else printf("系统中无该商品记录!press enter return!n");getchar();system("cls");return; 修改函数设计void xiugai(struct goods *head)推荐精选struct goods *baocun(struct goods *head); int p,i=0; struct goods *p1,*p2; system("cls"); printf("请输入四位编号:"); scanf("%d",&
23、p); getchar(); if(p!=0) p1=head; while(p!=p1->number&&p1->next!=NULL) p2=p1; p1=p1->next; if(p=p1->number) printf("n 商品编号 t 名字 t 数目 t 价格:n"); printf(" %dt %st %dt %fn",p1->number,p1->name,p1->shumu,p1->jiage); printf("请输入要修改的新商品编号 "); sca
24、nf("%d",&p1->number); 推荐精选 i=1; if(i=1) printf("修改后新商品编号 名字 数目 价格:n"); printf("%d %s %d %f",p1->number,p1->name,p1->shumu,p1->jiage); printf("修改成功!n"); baocun(head); 销售函数设计void xiaoshu(struct goods *head)struct goods *baocun(struct goods *he
25、ad);推荐精选 int c; int p; struct goods *p1,*p2; system("cls"); printf("请输入四位编号:"); scanf("%d",&p); getchar(); p1=head; while(p!=p1->number&&p1->next!=NULL) p2=p1; p1=p1->next; if(p=p1->number) printf("n 商品编号 t 商品名 t 数量 t 价格 n"); printf(&qu
26、ot;%dtt%stt%dtt%fn",p1->number,p1->name,p1->shumu,p1->jiage); printf("请输入该商品售货个数:"); scanf("%d",&c);推荐精选 p1->shumu=p1->shumu-c; printf("该商品经货个数:%dn",p1->shumu); baocun(head);三 程序清单#include<stdio.h>#include<string.h>#include<s
27、tdlib.h>#include<malloc.h>#define LEN sizeof(struct goods)struct goods 结构体int number; 商品编号char name20; 商品名int shumu; 商品数目推荐精选float jiage;商品价格struct goods *next;int n,k; 全局变量struct goods *head; 全局变量void main() 主函数 void jieman(); 界面函数声明 void luru(); 录入函数声明 struct goods *shuju(); 数据读取函数声明 void
28、 shanchu(struct goods *head); 删除函数声明 void jinghuo(struct goods *head); 进货函数声明 void xiaoshu(struct goods *head); 销售函数声明 void xiugai(struct goods *head); 修改函数声明 void chaxun(struct goods *head); 查询函数声明 struct goods *head=NULL; int k=0; system("cls"); jieman(); printf("请选择你要的功能键:");
29、scanf("%d",&k);getchar(); while(k!=0)推荐精选 head=shuju(); switch(k) case 1:luru();break; case 2:xiugai(head);break; case 3:chaxun(head);break; case 4:xiaoshu(head);break; case 5:jinghuo(head);break; case 6:shanchu(head);break; case 0:exit(0); default:printf("please try again!n"
30、); jieman(); printf("请选择你要的功能键:"); scanf("%d",&k); struct goods *baocun(struct goods *head) 保存函数推荐精选 struct goods *shuju(); struct goods *p=NULL; FILE *fp=NULL; char ch='0' getchar(); printf("是否保存到文件?(y/n):");判断是否保存 ch=getchar(); putchar(10); if(ch='y
31、9;|ch='Y') fp=fopen("goods.txt","wb"); p=head; if(fp=NULL)&&(p=NULL) printf("读取数据失败!"); exit(0); while(p!=NULL) fprintf(fp,"%dn%sn%dn%ft",p->number,p->name,p->shumu,p->jiage);推荐精选 p=p->next; printf("保存成功!n"); fclose(fp)
32、; return(head); else if(ch='n'|ch='N') printf("信息未保存到文件!n"); head=shuju(); return(head); else printf("sorry,please try again(y/n):"); ch=getchar(); putchar(10); return(head); 推荐精选void chaxun(struct goods *head) 查询函数 int a,c,i=0; struct goods *p1,*p2; char t20; pri
33、ntf(" 1*商品编号查询n"); printf(" 2*商品名字查询n"); printf("请选择你需要的功能键n"); scanf("%d",&a); getchar(); if(a=1) printf("请输入四位编号:"); scanf("%d",&c);getchar(); while(c!=0&&i=0) p1=head; while(c!=p1->number&&p1->next!=NULL) 查找
34、商品 p2=p1;p1=p1->next;推荐精选 if(c=p1->number) printf("n 商品编号 t 名字 t 数目 t 价格:n"); printf(" %dt %st %dt %.2fn",p1->number,p1->name,p1->shumu,p1->jiage);i=1; else printf("系统中无该商品记录!press enter return!n");getchar();system("cls");return; if(a=2&&
35、amp;i=0) system("cls");printf("请输入商品名字:"); scanf("%s",&t);getchar(); while(strcmp(t,"0")!=0&&i=0) p1=head; if(strcmp(t,p1->name)!=0&&p1->next!=NULL)查找商品 p2=p1;p1=p1->next; if(strcmp(t,p1->name)=0) printf("n 商品编号 t 名字 t 数目 t
36、 价格:n");推荐精选 printf(" %dt %st %dt %fn",p1->number,p1->name,p1->shumu,p1->jiage);i=1;else printf("系统中无该商品记录!press enter return!n");getchar();system("cls");return; void jinghuo(struct goods *head) 进货函数struct goods *baocun(struct goods *head); int c; int p
37、; struct goods *p1,*p2; system("cls"); printf("请输入四位编号:"); scanf("%d",&p); p1=head; while(p!=p1->number&&p1->next!=NULL) 查找商品 p2=p1;推荐精选 p1=p1->next; if(p=p1->number) printf("n 商品编号 t 商品名 t 数量 t 价格 n"); printf("%dtt%stt%dtt%fn"
38、;,p1->number,p1->name,p1->shumu,p1->jiage); printf("请输入该商品经货个数:"); scanf("%d",&c); p1->shumu=p1->shumu+c; printf("该商品经货个数:%dn",p1->shumu); baocun(head); 保存数据 void luru()struct goods *shuju(); 调用函数struct goods *baocun(struct goods *head);推荐精选stru
39、ct goods *p1,*p2,*p3;head=shuju();p1=head;p2=(struct goods *)malloc(LEN);printf("请输入四位编号:");scanf("%d",&p2->number);printf("请输入商品名:");scanf("%s",p2->name);printf("请输入商品数量:");scanf("%d",&p2->shumu);printf("请输入商品价格:"
40、;);scanf("%f",&p2->jiage);if(p1=NULL)p1=p2;p2->next=NULL;baocun(p2);return;while(p1!=NULL)p3=p1;p1=p1->next;p3->next=p2;p2->next=NULL;推荐精选baocun(head); 保存数据 void shanchu(struct goods *head) 删除函数struct goods *p1,*p2;struct goods *baocun(struct goods *head);int p;system(&q
41、uot;cls");printf("请输入四位编号:");scanf("%d",&p);p1=head;while(p!=p1->number&&p1->next!=NULL) 查找商品p2=p1;p1=p1->next;if(p=p1->number)printf("n商品编号 t商品名 t 数量 t 价格 n");printf(" %dtt%stt%dtt%.2fn",p1->number,p1->name,p1->shumu,p1-&
42、gt;jiage);if(p1=head) head=p1->next;else p2->next=p1->next;n=n-1; printf("删除成功!n");推荐精选 baocun(head); struct goods *shuju() 数据读取函数 int n=0; FILE *fp; struct goods *head=NULL,*p1,*p2; fp=fopen("goods.txt","rb"); if(fp=NULL) printf("nsorry,读取数据失败!n"); e
43、xit(0); else p1=p2=(struct goods *)malloc(LEN); fscanf(fp,"%d%s%d%f",&p1->number,p1->name,&p1->shumu,&p1->jiage); while(!feof(fp)推荐精选 n+; if(n=1)head=p1; else p2->next=p1; p2=p1; p1=(struct goods *)malloc(LEN); fscanf(fp,"%d%s%d%f",&p1->number,p1
44、->name,&p1->shumu,&p1->jiage); p2->next=NULL; fclose(fp); return(head); void jieman() 界面函数 printf("*n"); printf("欢迎进入商品管理系统n"); printf("*1 *录入信息*n"); printf("*2 *修改信息*n");推荐精选 printf("*3 *查询信息*n"); printf("*4 *销售信息*n"); printf("*5 *进货信息*n"); printf("*6 *删除信息*n"); printf("*0 *退出系统*n"); printf("欢迎进入商品管理系统n"); printf("*n"); void xiaoshu(struct goods *head) 销售函数struct goods *baocun(struct goods *head); int c; int p; struct goods *p1,*p2; system("cls");
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025 高中信息技术数据与计算之数据挖掘的聚类算法的谱聚类算法应用课件
- 春季祭祀扫墓防火安全指南
- 农业机械使用技术全解析
- 2026年能源行业TCFD披露:转型风险与物理风险双重暴露
- 2026年气候情景分析韧性评估企业落地实施实务
- 2026年银行智能体应用场景全景图:零售 对公 财富 运营
- 2026年手术机器人术中导航与配准精度评价方法
- 2026年低空空域北斗基准站增强信号覆盖评估报告
- 2026年高光谱成像检测装备农产品品质分级应用
- 2026年ECMO围手术期抗凝管理目标与监测指标指南
- (广东一模)2026年广东省高三高考模拟测试(一)英语试卷(含官方答案)
- 食品安全管理制度
- 2026中国石化云南石油分公司加能站后备站长招聘150人易考易错模拟试题(共500题)试卷后附参考答案
- 业务跟单工作制度
- 2026年河南省公务员录用考试申论真题
- 人教版(2024)物理 八年级下册 第七章 力 章末练习(无答案)
- 城市供水系统维护与应急处理操作手册(标准版)
- 部编版六年级下册道德与法治全册优秀课件
- 消防调试方案87487
- 中国经典广告案例评析之公益广告课件
- EPC合同条件(银皮书)-1999
评论
0/150
提交评论