已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 心灵成长小学主题班会课件
- 呼吸系统疾病的护理风险评估
- 催办付款逾期账款执行函(6篇)范文
- 红领巾挂牌仪式小学主题班会课件
- 共建无毒校园守护学生未来小学主题班会课件
- 习惯养成从现在开始主题小学主题班会课件
- 阅读时光:书中的世界小学主题班会课件
- 2026中国青年政治学院面向应届毕业生招聘科研助理10人考试备考试题及答案详解
- 小学生如何保护自己小学主题班会课件
- 孕期体重管理
- 2026年济宁银行人员招聘笔试参考试题及答案详解
- 2026年统编版三年级语文下册期末测试卷(含答案)
- 2026四川凉山州西昌学院劳务招聘图书馆工作人员1人笔试参考题库及答案详解
- 2025年济宁银行校园招聘笔试考试试题及答案详解
- 2025-2026学年统编版历史七年级下册小论文合集
- 2026版特种设备目录
- 西充县多扶初级中学项目
- 【新教材】统编版(2024)八年级下册历史期中复习:小论文 专项练习题(含答案解析)
- 雨课堂学堂在线学堂云《学术英语:研究论文写作与演讲(北京航空航天)》单元测试考核答案
- 《油气输送管道工程地质灾害防治设计规范》SYT 7040-2021
- 2026年医保结算流程培训课件
评论
0/150
提交评论