




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
超市商品管理系统中文提示By AzxXINER#include #include #include #include /-/Max count of good,def 100 temporary/-#define MAX 100int current_cnt = 0;/-/Good Information Definition/-typedef struct GoodInfochargood_id30;chargood_name30;chargood_price10;chargood_discount10;intgood_amount;intgood_remain;GoodInfo;GoodInfo *GoodsMAX;/-/free goodinfo memory/-void freeGoodInfo()int i = 0;for(i = 0;i good_id);fscanf(fp,t%s,&pGoodInfo-good_name);fscanf(fp,t%s,&pGoodInfo-good_price);fscanf(fp,t%s,&pGoodInfo-good_discount);fscanf(fp,t%d,&pGoodInfo-good_amount);fscanf(fp,t%dn,&pGoodInfo-good_remain);return pGoodInfo;/-/check whether the file exists or not/-int check_nullfile()FILE *fp = fopen(F:课程C语言程序设计综合实验2超市商品管理系统goodinfo.txt,r);/file not existif(!fp)printf(商品信息初始化文件不存在!n请您放到E盘根目录!n);fp = fopen(F:课程C语言程序设计综合实验2超市商品管理系统goodinfo.txt,w);fclose(fp);/file already existelseint temp;/res for try to read file if file null feof() cant jarge if file is nullint res = fscanf(fp,%d,&temp);fclose(fp);if(res=0)return -1;elsereturn 1;/-/initialize/-void info_init()int i = 0,j = 0;int res = check_nullfile();FILE *fp = fopen(F:课程C语言程序设计综合实验2超市商品管理系统goodinfo.txt,r);for(i=0; igood_id);fprintf(fp,%st,pGoodInfo-good_name);fprintf(fp,%st,pGoodInfo-good_price);fprintf(fp,%st,pGoodInfo-good_discount);fprintf(fp,%dt,pGoodInfo-good_amount);fprintf(fp,%dn,pGoodInfo-good_remain);/-/write all goodinfos into file/-void info_flush()int i = 0;FILE *fp = fopen(F:课程C语言程序设计综合实验2超市商品管理系统goodinfo.txt,w);for(i=0; igood_id, Goodsi-good_name);printf(商品价格:%st商品折扣:%st, Goodsi-good_price,Goodsi-good_discount);printf(商品数量:%dt商品剩余:%dtnn ,Goodsi-good_amount, Goodsi-good_remain);/-/modify a goodinfo/-int info_change()int i;if ( -1 = (i = info_search() )return 0;elseprintf(输入新的商品信息(以换行符区分信息条目):n);scanf(%sn,Goodsi - good_id);scanf(%sn,Goodsi - good_name);scanf(%sn,Goodsi - good_price);scanf(%sn,Goodsi - good_discount);scanf(%dn,&Goodsi - good_amount);scanf(%d,&Goodsi - good_remain);printf(商品信息修改成功!nn);return 0;/-/delete a goodinfo/-int info_dele()int i;if (current_cnt 0)if ( -1 = (i = info_search() )return 0;elsefree(Goodsi);/Goodsi = NULL;printf(删除商品信息成功!nn);current_cnt-;return 0;elseprintf(没有任何商品信息!);return 0;/-/ search a goodinfo/-int info_search()int i;char name20;scanf(%s,name);for ( i = 0; i good_name) = 0)printf(查询到以下信息:n);info_output(i);return i;if (i = current_cnt)printf(该商品不存在!nn);return -1;/-/insert one goodinfo/-void info_insert()int i = current_cnt;if (i good_id);scanf(%sn,Goodsi - good_name);scanf(%sn,Goodsi - good_price);scanf(%sn,Goodsi - good_discount);scanf(%dn,&Goodsi - good_amount);scanf(%d,&Goodsi - good_remain);current_cnt+;printf(插入商品信息成功!nn);info_output(i);elseprintf(商品信息过多,无法再插入新的信息!);/-/start UI/-void start()printf(超市商品管理系统n*n* 1.商品信息的修改: *n* 2.删除某个商品信息: *n* 3.查找某个商品信息: *n* 4.插入某个商品信息: *n* 其他.退出系统. *n*n* 请输入你的选择:);/-/main entry/-int main(void)int choose = 0;info_init();while(1)start();scanf(%d,&choose);switch (choose)case 1:printf(请输入你要修改的商品的名称: );info_change();break;case 2:printf(请输入你要删除的商品的名称: );info_dele();break;case 3:printf(请输入你要查询的商品的名称: );info_search();break;case 4:printf(请输入你要插入的商品的信息(以换行符区分信息条目):n);info_
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 产品质量问题追溯体系缺陷产品管理工具
- 合作社农民互助合同
- 小区公共绿化与园艺服务协议
- 2025年钳工(高级)考试试卷:综合技能与创新能力
- 2025年美容师(初级)美容师美容院绿色环保技能鉴定试卷
- 日语餐饮知识培训课件
- 2024年新网银行招聘笔试真题
- 秦淮区高一数学试卷
- 山西忻州忻府区社区专职工作者招聘考试真题2024
- 青岛版初三数学试卷
- 人教版2024-2025学年九年级英语下册教学计划(及进度表)
- T-NAHIEM 121-2024 创伤中心建设与设备配置规范
- 《磁感应强度-磁通量》课件
- 人教版九年级下册数学教学计划(及进度表)
- 业务协同与合并抵销报表方案汇报v1.9
- 标准预防及安全注射
- 儿童体适能教学 课件 (20期)
- 本质安全的概念和意义
- 2025-2030年中国少儿英语培训市场发展状况及投资前景规划研究报告
- 常用公文写作规范培训
- 《玉米病虫害及防治》课件
评论
0/150
提交评论