ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:17.52KB ,
资源ID:4071855      下载积分:2 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-4071855.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c语言实践实验设备管理完整.docx)为本站会员(b****4)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

c语言实践实验设备管理完整.docx

1、c语言实践实验设备管理完整中国地质大学(武汉)机械设计制造及其自动化专业072105陈乾#include#include#define AMOUNT 50typedef struct int year。 int month。 int day。DATE。struct EQU int num。 /*本程序默认设备编号各不相同且不为0*/ char type20。 char name20。 int price。 DATE buy_time。 int scrap。 /*0表示报废1表示不报废*/ DATE scr_time。equAMOUNT。 /*公共函数 保存与加载函数*/void save()

2、FILE *fp。 int i。 if(fp=fopen(record,wb)=NULL) printf(cannot open filen)。 for(i=0。iAMOUNT。i+) if(fwrite(&equi,sizeof(struct EQU),1,fp)!=1) printf(file write errorn)。 fclose(fp)。void load() FILE *fp。 int i。 if(fp=fopen(record,rb)=NULL) printf(cannot open filen)。 for(i=0。inum!=0)p+。 printf(请输入设备编号n)。 s

3、canf(%d,&p-num)。 printf(请输入设备种类n)。 scanf(%s,p-type)。 printf(请输入设备名称n)。 scanf(%s,p-name)。 printf(请输入设备价格n)。 scanf(%d,&p-price)。 printf(请输入设备购买日期 年 月 日以空格隔开n)。 scanf(%d%d%d,&p-buy_time.year,&p-buy_time.month,&p-buy_time.day)。 p-scrap=1。 p-scr_time.year=0。 p-scr_time.month=0。 p-scr_time.day=0。 printf(n

4、以下记录录入成功n)。 printf(编号:%d 设备种类:%s 设备名称:%sn价格:%d 购买日期:%d %d %dn是否报废:%d 报废日期:%d %d %d n,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 printf(继续录入请按1,退出请按2n)。 scanf(%d,&flag)。 while(flag=1)。 save()。/*修改模块*/void chang

5、e() int flag,n,i=0。 struct EQU *p。 p=equ。 load()。 printf(请输入要更改的设备编号n)。 scanf(%d,&flag)。 for(i=0,p=equ。inum=flag) do printf(请输入要更改的信息:n1设备编号n2设备种类n3设备名称n4设备价格n5购买日期n6是否报废n7退出n)。 scanf(%d,&n)。 switch(n) case 1: printf(请输入新的设备编号n)。 scanf(%d,&p-num)。break。 case 2: printf(请输入新的设备种类n)。 scanf(%s,p-type)。b

6、reak。 case 3: printf(请输入新的设备名称n)。 scanf(%s,p-name)。break。 case 4: printf(请输入新的价格n)。 scanf(%d,&p-price)。break。 case 5: printf(请输入新的设备购买日期 年 月 日n)。 scanf(%d%d%d,&p-buy_time.year,&p-buy_time.month,&p-buy_time.day)。break。 case 6: printf(请输入是否报废设备n)。 scanf(%d,&p-scrap)。 printf(请输入报废日期n)。 scanf(%d%d%d,&p-

7、scr_time.year,&p-scr_time.month,&p-scr_time.day)。 break。 case 7: break。 while(n!=7)。 printf(修改后的记录为:)。 printf(编号:%d 设备种类:%s 设备名称:%sn价格:%d 购买日期:%d %d %dn是否报废:%d 报废日期:%d %d %d n,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_t

8、ime.day)。 save()。/*查询模块*/void search() int n,num,i,year,month,day。 char s20。 struct EQU *p。 p=equ。 load()。 do printf(1.按编号查询n)。 printf(2.按设备种类查询n)。 printf(3.按设备名称查询n)。 printf(4.按购买日期查询n)。 printf(5.查询正常的设备n)。 printf(6.退出n)。 scanf(%d,&n)。 switch(n) case 1: printf(请输入要查询的设备编号n)。 scanf(%d,&num)。 for(i=0

9、,p=equ。inum=num) printf(编号:%d 设备种类:%s 设备名称:%sn价格:%d 购买日期:%d %d %dn是否报废:%d 报废日期:%d %d %d n,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 2: printf(请输入要查询的设备种类n)。 scanf(%s,s)。 for(i=0,p=equ。itype)=0) pr

10、intf(编号:%d 设备种类:%s 设备名称:%s价格:%d 购买日期:%d %d %d 是否报废:%d 报废日期:%d %d %dn,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 3: printf(请输入要查询的设备名称n)。 scanf(%s,s)。 for(i=0,p=equ。iname)=0) printf(编号:%d 设备种类:%s 设备

11、名称:%s价格:%d 购买日期:%d %d %d 是否报废:%d 报废日期:%d %d %dn,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 4: printf(请输入要查询的设备购买日期 年 月 日n)。 scanf(%d%d%d,&year,&month,&day)。 for(i=0,p=equ。ibuy_time.year&month=p-buy

12、_time.month&day=p-buy_time.day) printf(编号:%d 设备种类:%s 设备名称:%s价格:%d 购买日期:%d %d %d 是否报废:%d 报废日期:%d %d %dn,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 5: printf(未报废的设备有:n)。 for(i=0,p=equ。iscrap=1) print

13、f(编号:%d 设备种类:%s 设备名称:%s价格:%d 购买日期:%d %d %d 是否报废:%d 报废日期:%d %d %dn,p-num,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 6: break。 while(n!=6)。/*统计模块*/void statis() int flag,n,i,j,k=0。 char s20。 struct EQU *p。

14、 struct EQU strAMOUNT,str11。 p=equ。 load()。 printf(请输入要查询的设备种类n)。 scanf(%s,&s0)。 for(i=0,n=0,p=equ。itype)=0) strn.num=p-num。 strn.price=p-price。 strcpy(strn.name,p-name)。 strn.scrap=p-scrap。 strcpy(strn.type,p-type)。 strn.buy_time.year=p-buy_time.year。 strn.buy_time.month=p-buy_time.month。 strn.buy_

15、time.day=p-buy_time.day。 strn.scr_time.day=p-scr_time.day。 strn.scr_time.month=p-scr_time.month。 strn.scr_time.year=p-scr_time.year。 n+。 /*以上程序是将需要查询的设备种类的所有设备信息存入数组str中*/ do printf(1.按编号排序n)。 printf(2.按价格排序n)。 printf(3.按购买日期排序n)。 printf(4.退出n)。 /*这段程序之后出错*/ scanf(%d,&flag)。 switch(flag) case 1: for

16、(j=0。jn-1。j+) /*起泡法排序*/ for(i=0。istri+1.num) str10.num=stri.num。 str10.buy_time.day=stri.buy_time.day。 /*t=ai*/ str10.buy_time.month=stri.buy_time.month。 str10.buy_time.year=stri.buy_time.year。 str10.scr_time.year=stri.scr_time.year。 str10.scr_time.month=stri.scr_time.month。 str10.scr_time.day=stri.

17、scr_time.day。 str10.price=stri.price。 str10.scrap=stri.scrap。 strcpy(str10.name,stri.name)。 strcpy(str10.type,stri.type)。 stri.num=stri+1.num。 stri.buy_time.day=stri+1.buy_time.day。 /*ai=ai+1*/ stri.buy_time.month=stri+1.buy_time.month。 stri.buy_time.year=stri+1.buy_time.year。 stri.scr_time.year=str

18、i+1.scr_time.year。 stri.scr_time.month=stri+1.scr_time.month。 stri.scr_time.day=stri+1.scr_time.day。 stri.price=stri+1.price。 stri.scrap=stri+1.scrap。 strcpy(stri.name,stri+1.name)。 strcpy(stri.type,stri+1.type)。 stri+1.num=str10.num。 stri+1.buy_time.day=str10.buy_time.day。 /*ai+1=t*/ stri+1.buy_tim

19、e.month=str10.buy_time.month。 stri+1.buy_time.year=str10.buy_time.year。 stri+1.scr_time.year=str10.scr_time.year。 stri+1.scr_time.month=str10.scr_time.month。 stri+1.scr_time.day=str10.scr_time.day。 stri+1.price=str10.price。 stri+1.scrap=str10.scrap。 strcpy(stri+1.name,str10.name)。 strcpy(stri+1.type

20、,str10.type)。 for(i=0,p=str。inum,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 2: for(j=0。jn-1。j+) /*起泡法排序*/ for(i=0。i=stri+1.price) str10.num=stri.num。 str10.buy_time.day=stri.buy_time.day。 /*t=ai*/ str10.

21、buy_time.month=stri.buy_time.month。 str10.buy_time.year=stri.buy_time.year。 str10.scr_time.year=stri.scr_time.year。 str10.scr_time.month=stri.scr_time.month。 str10.scr_time.day=stri.scr_time.day。 str10.price=stri.price。 str10.scrap=stri.scrap。 strcpy(str10.name,stri.name)。 strcpy(str10.type,stri.typ

22、e)。 stri.num=stri+1.num。 stri.buy_time.day=stri+1.buy_time.day。 /*ai=ai+1*/ stri.buy_time.month=stri+1.buy_time.month。 stri.buy_time.year=stri+1.buy_time.year。 stri.scr_time.year=stri+1.scr_time.year。 stri.scr_time.month=stri+1.scr_time.month。 stri.scr_time.day=stri+1.scr_time.day。 stri.price=stri+1

23、.price。 stri.scrap=stri+1.scrap。 strcpy(stri.name,stri+1.name)。 strcpy(stri.type,stri+1.type)。 stri+1.num=str10.num。 stri+1.buy_time.day=str10.buy_time.day。 /*ai+1=t*/ stri+1.buy_time.month=str10.buy_time.month。 stri+1.buy_time.year=str10.buy_time.year。 stri+1.scr_time.year=str10.scr_time.year。 stri

24、+1.scr_time.month=str10.scr_time.month。 stri+1.scr_time.day=str10.scr_time.day。 stri+1.price=str10.price。 stri+1.scrap=str10.scrap。 strcpy(stri+1.name,str10.name)。 strcpy(stri+1.type,str10.type)。 for(i=0,p=str。inum,p-type,p-name,p-price,p-buy_time.year,p-buy_time.month,p-buy_time.day,p-scrap,p-scr_time.year,p-scr_time.month,p-scr_time.day)。 break。 case 3: /*由于程序过于复杂 需连续用3次起泡法 所以按购买日期排序只对年份排序*/ for(j=0。jn-1。j+) /*起泡法排序*/ for(i=0。in-1-j。i+) if(stri.buy_ti

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2