![C语言宠物商店管理系统实训报告_第1页](http://file3.renrendoc.com/fileroot_temp3/2022-1/14/e2d6b48a-9177-4824-8eba-022c1dd89ea5/e2d6b48a-9177-4824-8eba-022c1dd89ea51.gif)
![C语言宠物商店管理系统实训报告_第2页](http://file3.renrendoc.com/fileroot_temp3/2022-1/14/e2d6b48a-9177-4824-8eba-022c1dd89ea5/e2d6b48a-9177-4824-8eba-022c1dd89ea52.gif)
![C语言宠物商店管理系统实训报告_第3页](http://file3.renrendoc.com/fileroot_temp3/2022-1/14/e2d6b48a-9177-4824-8eba-022c1dd89ea5/e2d6b48a-9177-4824-8eba-022c1dd89ea53.gif)
![C语言宠物商店管理系统实训报告_第4页](http://file3.renrendoc.com/fileroot_temp3/2022-1/14/e2d6b48a-9177-4824-8eba-022c1dd89ea5/e2d6b48a-9177-4824-8eba-022c1dd89ea54.gif)
![C语言宠物商店管理系统实训报告_第5页](http://file3.renrendoc.com/fileroot_temp3/2022-1/14/e2d6b48a-9177-4824-8eba-022c1dd89ea5/e2d6b48a-9177-4824-8eba-022c1dd89ea55.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、word可编辑实 训 报 告实训工程:宠物商店管理系统院别专业:信息管理学院班级学号:学生姓名:煜指导教师:实训成绩:实验日期:2022年6月8日制信息管理学院实践教学中心一、 实训目的:1掌握C语法,函数,界面程序设计,文件操作。2掌握C文件编程方法。二、 实训内容及要求:用C语言设计基于文件的宠物商店管理系统。要求具有信息显示、录入、修改、查询和删除的界面并完成相关功能。三、实训方案:系统功能结构、主要界面与主要代码:1.功能结构如下:以下列图仅供参考,以实际所做的系统功能为准!2.主要功能介绍:1添加宠物类型。2修改宠物类型。3显示添加的全部宠物类型。4显示宠物全部的交易记录。5显示宠物
2、月度交易统计数据。6显示主功能菜单3主要代码:#include<stdio.h>#include<time.h>#include<string.h>#define SIZE 3#define SIZET 100struct pettypeint typeId;char name20;int petstore;pettypesSIZE;struct pettransinfoint transId;int typeId;int num;int transtype;int year;int month;int day;pettransinfosSIZET;int
3、getcurrenttypeindex();int getcurrenttypeinfoindex();int getcurrenttransinfoindex();/*添加宠物类型*/void tjcwlx();/*修改宠物类型*/void xgcwlx();/*显示全部的宠物类型*/void tjqbdcwlx();/*添加宠物进货记录*/void tjcwxsjl();/*添加宠物销售记录*/void xscwqbjyjl();/*显示宠物全部交易记录*/void xscwjytjxx();/*显示宠物交易统计信息*/void xszgncd();/*显示主功能菜单*/void show
4、menu();int istypeexistsbyId(int typeId);int updatepetstore(int typeId,int num);int main(int argc,const char * argv)showmenu();return 0;void showmenu()int n;do system("cls");printf(" *n");printf(" * 欢送使用宠物商店 *n");printf(" * = *n");printf(" * 1.添加宠物类型 *n&qu
5、ot;);printf(" * 2.修改宠物类型 *n");printf(" * 3.显示全部宠物类型 *n");printf(" * 4.添加宠物进货记录 *n");printf(" * 5.添加宠物销售记录 *n");printf(" * 6.显示宠物全部交易记录 *n");printf(" * 7.显示宠物月度交易统计数据 *n");printf(" * 8.退出 *n");printf(" *n");printf("请
6、选择您需要的操作:");scanf("%d",&n);switch(n)case 1:tjcwlx();break;case 2:xgcwlx();break;case 3:tjqbdcwlx();break;case 4:tjcwxsjl();break;case 5:xscwqbjyjl();break;case 6:xscwjytjxx();break;case 7:xszgncd();break;case 8:printf("欢送你再次使用宠物商店系统n");return;default:break; printf("
7、按回车继续!n"); fflush(stdin); getchar(); getchar();while(1);/*添加宠物类型*/void tjcwlx() int typeId;char typeName20;typeId=getcurrenttypeindex();if(typeId=-1)printf("当前宠物类型的数量已达上限,无法再次添加!n");return ;printf("请输入新增宠物类型:");scanf("%s",typeName);pettypestypeId-1.typeId=typeId;st
8、rcpy(pettypestypeI,typeName); pettypestypeId-1.petstore=0; printf("新宠物类型%s,已经添加成功!n", typeName);/*修改宠物类型*/void xgcwlx()int typeId; char typeName20;printf("请输入需要修改宠物类型编号:"); scanf("%d",&typeId);if(istypeexistsbyId(typeId)=-1)printf("当前系统不存在您输入的宠物类型编号!n&q
9、uot;);return;elseprintf("名称:%sn", pettypestypeId - 1.name);printf("请输入修改后的宠物名称:");scanf("%s",typeName);strcpy(pettypestypeI,typeName);printf("编号是%d的宠物类型名称已经改成%s!n", typeId,typeName);/*显示全部的宠物类型*/void tjqbdcwlx()int i;printf("类型编号t类型名称n");for(
10、i=0;i<SIZE;i+)if(pettypesi.typeId=0)break;printf("%3dtt%sn",pettypesi.typeId,);/*添加宠物进货记录*/void tjcwxsjl()int transId;int typeId;int purchasenum;time_t tp;struct tm *p;time(&tp);p = localtime(&tp);transId=getcurrenttransinfoindex();if(transId=-1)printf("宠物交易记录
11、次数已经到达上限,无法再次进货!");return ;printf("请输入本次进货的宠物类型编号:");scanf("%d",&typeId);if(istypeexistsbyId(typeId)=-1)printf("当前系统不存在您输入的宠物类型编号!n");return;printf("请输入本次宠物进货的数量:");scanf("%d",&purchasenum);if(purchasenum<1)printf("进货数量不能小于1,操作失败
12、!n");return ;time(&tp);p=gmtime(&tp);pettransinfostransId-1.year=p->tm_year+1900;pettransinfostransId-1.month=p->tm_mon+1;pettransinfostransId-1.day=p->tm_mday; /strftime(pettransinfostransId - 1.data, sizeof(pettransinfostransId - 1.data), "%Y-%m-%d", localtime(&
13、tp);pettransinfostransId-1.transId=transId;pettransinfostransId-1.typeId=typeId;pettransinfostransId-1.num=purchasenum;pettransinfostransId-1.transtype=0;updatepetstore(typeId,purchasenum,1);printf("本次宠物进货完成记录!");/*添加宠物销售记录*/void xscwqbjyjl()int transId;int typeId;int purchasenum;time_t tp
14、;struct tm *p;time(&tp);p = localtime(&tp);transId = getcurrenttransinfoindex();if (transId = -1)printf("宠物交易记录次数已经到达上限,无法再次销售!");return;printf("请输入本次销售的宠物类型编号:");scanf("%d", &typeId);if (istypeexistsbyId(typeId) = -1)printf("当前系统不存在您输入的宠物类型编号!n");
15、return;printf("请输入本次销售的宠物数量:");scanf("%d", &purchasenum);if (purchasenum>pettypestypeId-1.petstore)printf("当前该类型宠物的库存数量缺乏,无法进行销售!n");return;time(&tp);p = gmtime(&tp);pettransinfostransId - 1.year = p->tm_year + 1900;pettransinfostransId - 1.month = p-&
16、gt;tm_mon + 1;pettransinfostransId - 1.day = p->tm_mday;/strftime(pettransinfostransId - 1.data, sizeof(pettransinfostransId - 1.data), "%Y-%m-%d", localtime(&tp);pettransinfostransId - 1.transId = transId;pettransinfostransId - 1.typeId = typeId;pettransinfostransId - 1.num = purch
17、asenum;pettransinfostransId - 1.transtype = 1;updatepetstore(typeId, purchasenum,2);printf("本次宠物销售完成记录!");/*显示宠物全部交易记录*/void xscwjytjxx()int i;char *name;printf("宠物编号t宠物名称t交易数量t交易日期t交易类型n");for (i = 0; i<SIZET; i+)if (pettransinfosi.transId = 0)break;if (pettransinfosi.transty
18、pe = 0)name = "入库"else if(pettransinfosi.transtype = 1)name = "售出"elsename = "未知"printf("%3dtt%stt%3dtt%d-%d-%dt%sn", pettransinfosi.typeId, pettypespettransinfosi.typeI,pettransinfosi.num, pettransinfosi.year, pettransinfosi.month, pettransinfosi.day,
19、 name);/*显示宠物交易统计信息*/void xszgncd()const char * split = "-"int i;char *name;int month;int j;int purchasenum=0;int salenum=0;printf("请输入需要查看的月份:");scanf("%d", &month);printf("类型编号t类型名称t入库数量t销售数量t库存数n");for (i = 0; i<SIZE; i+)if (pettypesi.typeId = 0)brea
20、k;for (j = 0; j<SIZET; j+)if (pettransinfosj.transId = 0)break;if (pettransinfosj.month = month&&pettransinfosj.typeId = pettypesi.typeId)if (pettransinfosj.transtype = 0)purchasenum += pettransinfosj.num;elsesalenum+= pettransinfosj.num;printf("%3dtt%stt%3dtt%3dtt%3dn", pettypesi.typeId, , purchasenum, salenum, purchasenum - salenum);int getcurrenttypeindex()int index=-1;int i;for(i=0;i<SIZE;i+) if(pettypesi.typeId=0)index=i+1;break;return index;int getcurrenttr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《义务教育法》知识考试复习题库(含答案)
- (技师)化学检验工职业技能鉴定理论考试题库(含答案)
- 年产1000吨纳米复合氧化锆项目可行性研究报告写作模板-申批备案
- 2025年江西外语外贸职业学院高职单招职业适应性测试近5年常考版参考题库含答案解析
- 2025年新疆工业职业技术学院高职单招职业技能测试近5年常考版参考题库含答案解析
- 幼儿园月亮故事活动策划方案五篇
- 标线承包合同范本
- 精准医疗项目研发合作合同
- 麻雀的听评课记录
- 承揽货物运输合同范本
- 房地产调控政策解读
- 产前诊断室护理工作总结
- 2024-2025学年八年级数学人教版上册寒假作业(综合复习能力提升篇)(含答案)
- 《AP内容介绍》课件
- 医生定期考核简易程序述职报告范文(10篇)
- 安全创新创效
- 《中国糖尿病防治指南(2024版)》更新要点解读
- 初级创伤救治课件
- 2024年社会工作者(中级)-社会综合能力考试历年真题可打印
- 《处理人际关系》课件
- 五年级行程问题应用题100道
评论
0/150
提交评论