已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 卫生事业单位招聘考试(护理学)历年参考题库含答案详解(5套)
- 新北师大五年级下学期长方体体积的练习
- Android 数据库高频面试题(含详细真实面试答案)
- 文书档案的归档整.理方法模板
- 2026年四川省公务员录用考试行政职业能力测验终极押题密卷四-参考答案及解析
- 2026年特种设备安全员A证考试练习题及答案
- 2026年烟草招聘考试题及答案
- 2026年中级育婴师试题与参考答案试卷+答案
- XX省专业技术继续教育公需科目考试及答案
- 国家开放大学《城市管理学》形考任务作业参考答案
- GB/T 1685.1-2026硫化橡胶或热塑性橡胶压缩应力松弛的测定第1部分:恒定温度下试验
- 重庆市城市建设发展有限公司招聘笔试题库2026
- 职业卫生技术服务专业技术人员考试(职业卫生评价)例题及答案(北京市)
- 2026四川成都市公共交通集团有限公司招聘储备人才等岗位备考题库附答案详解(培优)
- 2026护理核心制度培训完整版
- DB21∕T 4374-2025 林业经营数表
- 2026年大数据智慧环保监测平台建设可行性方案
- 2026年福建社区工作者考试真题及答案
- 血透室工程师培训制度
- 河海大学介绍
- 心衰患者的监测指标解读
评论
0/150
提交评论