已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024招投标与合同管理教学大纲
- 深度解析(2026)《GBT 35778-2017企业标准化工作 指南》
- 深度解析(2026)《GBT 35713-2017船舶艏向控制系统》
- 深度解析(2026)《GBT 35413-2017应急导向系统 评价指南》
- 《DLT 967-2005回路电阻测试仪 直流电阻快速测试仪检定规程》(2026年)合规红线与避坑实操手册
- 考研英语二试题及分析
- 四川省巴中市2026年九年级下学期期中考试化学试题附答案
- 档案馆管理员档案试卷及分析
- 书法艺术题目及详解
- 影像科X线诊断题库及答案
- 2025注册验船师资格考试(B级船舶检验法律法规)综合能力测试题及答案一
- 基于PLC的采煤机监控系统设计
- 肾癌的护理课件教学
- (零诊)成都市2023级(2026届)高三高中毕业班摸底测试语文试卷(含答案)
- 电力市场交易培训
- DB1331∕T 054-2023 雄安新区建筑节能与绿色建筑工程施工质量验收标准
- DB31/T 552-2017大型商业建筑合理用能指南
- 药品营销策划合同协议
- 家校同心合力共育七年级期末家长会课件
- 煤矿围岩观测制度
- 水表安装施工合同范本
评论
0/150
提交评论