




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include#includeusing namespace std;const int m=100; /定义常量mclass Store /定义类private:int num; /编号char name20; /名称double price; /价格int quantity; /数量int amount; /数目public:void Input();int Input_2();void Dig();void Change();void Search_num();void Search_name();void Show();void Short();void Delete();goodsm;void Store:Input() /创建表单int i,n;coutamount;coutendl;for(i=0;iamount;i+)cout这是第(i+1)货物信息endl;goodsi.num=i+1;;coutgoodsi.price;coutgoodsi.quantity;coutendl;coutn输入的信息:endl;for(i=0;iamount;i+)cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;ofstream os(goods.txt,ios_base:out|ios_base:binary); /创建、打开文件for(n=0;namount;n+)os.write( reinterpret_cast(&(goodsn),sizeof(Store) ); /导出文件os.close(); /关闭文件int Store:Input_2() /文件读入int i,n;ifstream is(goods.txt,ios_base:in|ios_base:binary);if(!is)cout打开失败endl;return 0;for(i=0;is.read( reinterpret_cast(goods+i) , sizeof(Store) );i+)amount=i;cout导入的表单:endl;for(n=0;namount;n+)cout货号:goodsn.numends;cout货品名:ends;cout单价:goodsn.priceends;cout库存量:goodsn.quantityendsendl;return 1;void Store:Dig() /插入信息int i,n,m;coutn;coutendl;for(i=0;in;i+)cout这是第(i+1)货物信息endl;goodsamount+i.num=amount+i+1;coutgoodsamount+;coutgoodsamount+i.price;coutgoodsamount+i.quantity;coutn输入的信息endl;for(i=0;iamount+n;i+)cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;amount=amount+n;ofstream os(goods.txt,ios_base:out|ios_base:binary); /创建、打开文件for(m=0;mamount;m+)os.write( reinterpret_cast(&(goodsm),sizeof(Store) ); /导出文件os.close(); /关闭文件;void Store:Change() /修改信息int n,i,m;coutn;coutendl;cout请输入修改的信息endl;;coutgoodsn-1.price;coutgoodsn-1.quantity;coutendl;cout修改后的信息:endl;for(i=0;iamount;i+)cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;ofstream os(goods.txt,ios_base:out|ios_base:binary); /创建、打开文件for(m=0;mamount;m+)os.write( reinterpret_cast(&(goodsm),sizeof(Store) ); /导出文件os.close(); /关闭文件void Store:Search_num() /按编号查int n;coutn;coutendl;if(n=amount)cout货号:goodsn-1.numends;cout货品名:ends;cout单价:goodsn-1.priceends;cout库存量:goodsn-1.quantityendsamount)cout输入错误,请重新输入:amount);void Store:Search_name() /按名称查int flag = 0;int i;char x20;coutx;coutendl;for(i=0;iamount;i+)if(strcmp(,x)=0) /strcmp 用来比较字符串.tname和xflag = 1;cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;else;if (flag = 0)cout输入错误,请重新输入:ends;while(flag = 0);void Store:Show() /显示信息int i;for(i=0;iamount;i+)cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;void Store:Short() /查询不足货物int flag = 0;int i;int y;couty;coutendl;for(i=0;iamount;i+)if(goodsi.quantity=y)flag = 1;cout货号:goodsi.numends;cout货品名:ends;cout单价:goodsi.priceends;cout库存量:goodsi.quantityendsendl;else;if (flag = 0)cout没有货物,请重新输入:ends;while(flag = 0);void Store:Delete() /删除货物char y20;int n,m;couty;for(int i=0;iamount;i+)if(strcmp(,y)=0)/strcmp 用来比较字符串.tname和yfor(;iamount;i+)goodsi=goodsi+1;goodsi.num=i+1;amount=amount-1; /货物数减一cout删除后货单:endl;for(m=0;mamount;m+)cout货号:goodsm.numends;cout货品名:ends;cout单价:goodsm.priceends;cout库存量:goodsm.quantityendsendl;ofstream os(goods.txt,ios_base:out|ios_base:binary); /创建、打开文件for(n=0;namount;n+)os.write( reinterpret_cast(&(goodsn),sizeof(Store) ); /导出文件os.close(); /关闭文件;void Clear() /清屏函数char a;a=getchar();system(cls);void menuPrint() /主菜单coutt* 仓库管理 *endl;coutt* 1.输入货物信息 *endl;coutt* 2.查询货物信息 *endl;coutt* 3.显示货物信息 *endl;coutt* 4.显示不足货物 *endl;coutt* 5.删除货物信息 *endl;coutt* 6. 退出系统 *endl;coutt*endl;cout请输入你要进行的操作(16):n;coutendl;switch(n)case 1: /输入货物信息int a;cout 输入方式endl;cout1.创建表单endl;cout2.从文件导入endl;cout3.插入信息endl;cout4.修改信息endl;cout5.返回主菜单a;coutendl;switch(a)case 1: /调用创建函数Goods.Input();break;case 2: /调用文件读入函数Goods.Input_2();break;case 3: /调用增加函数Goods.Dig();break;case 4: /调用增加函数Goods.Change();break;case 5:break;default:cout您的输入有误,请重新选择endl;break;break;case 2: /查询int a;cout 查询方式endl;cout1.按编号查询endl;cout2.按名称查询endl;cout3.返回主菜单a;coutendl;switch(a)case 1: /调用函数(按货号查)Goods.Search_num();break;case 2: /调用函数(按货名查)Goods.Search_name();break;case 3:bre
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 安徽省颍上三中学2026届数学八年级第一学期期末质量跟踪监视模拟试题含解析
- 2025贵州安顺市参加“第十三届贵州人才博览会”引才招聘271人模拟试卷及完整答案详解
- 2025广西百色市平果市投资促进局城镇公益性岗位人员招聘1人模拟试卷附答案详解
- Brand KPIs for clean beauty Juice Beauty in the United States-外文版培训课件(2025.9)
- 安全培训落地课件
- 2025年上半年内江市部分学校公开考试招聘教师、部分事业单位公开考试招聘工作人员笔试模拟试卷及答案详解1套
- 2025贵州安顺市平坝区社会保险事业局招聘公益性岗位人员2人考前自测高频考点模拟试题及一套参考答案详解
- 2025黑龙江鸡西市融媒体中心招聘公益性岗位就业人员2人考前自测高频考点模拟试题及答案详解(网校专用)
- 2025年临沂郯城县技工学校公开招聘教师(26人)考前自测高频考点模拟试题及答案详解(历年真题)
- 2025江苏张家港检验认证有限公司招聘1人考前自测高频考点模拟试题及参考答案详解1套
- 2025年中国电信集团校园招聘笔试模拟试题集
- 全屋定制经销商合同协议
- 2024年仁怀市辅警真题
- 胸腺-胸腺瘤课件
- 供管水员知识培训课件
- 学堂在线 科学研究方法与论文写作 章节测试答案
- 精细化学品建设项目投资计划书
- 彗星光谱分析技术-洞察及研究
- 涉案财物处置培训
- 颈动脉支架概述
- DB3702∕T 22-2023 城市道路交通设施设置规范
评论
0/150
提交评论