【计算机类职业资格】三级信息管理技术机试-296及答案解析.doc

上传人:towelfact221 文档编号:1320767 上传时间:2019-10-17 格式:DOC 页数:4 大小:28KB
下载 相关 举报
【计算机类职业资格】三级信息管理技术机试-296及答案解析.doc_第1页
第1页 / 共4页
【计算机类职业资格】三级信息管理技术机试-296及答案解析.doc_第2页
第2页 / 共4页
【计算机类职业资格】三级信息管理技术机试-296及答案解析.doc_第3页
第3页 / 共4页
【计算机类职业资格】三级信息管理技术机试-296及答案解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级信息管理技术机试-296 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 in32.dat 中存有 300 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的个数 cnt,再求出所有满足此条件的 4 位数的平均值 pjz1,以及所有不满足此条件的 4 位数的平均值pjz2,最后调用函数 writeDat()把结果 cnt、pjz1、pjz2 输出到 out32.dat 文件中。例如:9123,

2、9-1-2-30,则该数满足条件,计算平均值 pjz1,且个数 cnt=cnt+1;9812,9-8-1-20,则该数不满足条件,计算平均值 pjz2。注意:部分源程序已给出。程序中已定义数组:a300,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 wfteDat()的内容。试题程序#includestdio.hint a300,cnt=0;double pjz1=0.0,pjz2=0.0;void readDat();void writeDat();void jsValue()voidmain()readDat();jsValue();writeDat

3、);printf(“cnt=%d/n 满足条件的平均值 pjz1=%7.2lf/n 不满足条件的平均值pjz2=%7.2lf/n“,cnt,pjz1,pjz2);void readDat()FILE*fp;int i;fP=fopen(“in32.dat“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE*fP:fP=fopen(“out32.dat“,“W“);fprintf(fp,“%d/n%7.2lf/n%7.2lf/n”,cnt,pjz1,pjz2);fclose(fp);(分数:100.00)_三

4、级信息管理技术机试-296 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 in32.dat 中存有 300 个 4 位数,并已调用读函数 readDat()把这些数存人数组 a 中,请编制一函数 jsValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的个数 cnt,再求出所有满足此条件的 4 位数的平均值 pjz1,以及所有不满足此条件的 4 位数的平均值pjz2,最后调用函数 writeDat()把结果 cnt、pjz1、pjz2 输出到 out32.dat 文件中。例如:9123,9-

5、1-2-30,则该数满足条件,计算平均值 pjz1,且个数 cnt=cnt+1;9812,9-8-1-20,则该数不满足条件,计算平均值 pjz2。注意:部分源程序已给出。程序中已定义数组:a300,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 wfteDat()的内容。试题程序#includestdio.hint a300,cnt=0;double pjz1=0.0,pjz2=0.0;void readDat();void writeDat();void jsValue()voidmain()readDat();jsValue();writeDat()

6、printf(“cnt=%d/n 满足条件的平均值 pjz1=%7.2lf/n 不满足条件的平均值pjz2=%7.2lf/n“,cnt,pjz1,pjz2);void readDat()FILE*fp;int i;fP=fopen(“in32.dat“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE*fP:fP=fopen(“out32.dat“,“W“);fprintf(fp,“%d/n%7.2lf/n%7.2lf/n”,cnt,pjz1,pjz2);fclose(fp);(分数:100.00)_正确答

7、案:(void jsValue()int i,n=0; /*定义循环变量和计数器变量*/int a1,a2,a3,a4; /*定义变量保存 4 位数的每位数字*/for(i=0;i300;i+) /*逐个取每一个 4 位数*/a4=ai/1000; /*求 4 位数的千位数字*/a3+ai%1000/100; /*求 4 位数的百位数字*/a2=ai%100/10; /*求 4 位数的十位数字*/al=ai%10; /*求 4 位数的个位数字*/if(a4-a3-a2-a10) /*如果千位数字减百位数字减十位数字减个位数字大于零*/cnt+; /*统计满足条件的数的个数*/pjz1+=ai;

8、 /*对满足条件的数求和*/elsen+; /*统计不满足条件的数的个数*/pjz2+=ai; /*对不满足条件的数求和*/pjz1/=cnt; /*求满足条件的数的平均值*/pjz2/=n; /*求不满足条件的数的平均值*/)解析:解析 根据题意可知,函数 jsValue()要实现两个功能:一是分别找出满足条件和不满足条件的数,并分别求出它们的平均值。首先找出满足条件的数,关键在于判断每个数的千位数字减百位数字减十位数字减个位数字的差是否大于零,此处通过 if 语句判断 4 位数是否符合该条件。其次,对符合条件和不符合条件的数分别进行统计。最后,再分别计算出满足条件的数和不满足条件的数的平均值。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 973-2009 Chemicals used for treatment of water intended for human consumption - Sodium chloride for regeneration of ion exchangers German version EN 973 2009《可供饮用水处理用化学试剂 立即.pdf DIN EN 973-2009 Chemicals used for treatment of water intended for human consumption - Sodium chloride for regeneration of ion exchangers German version EN 973 2009《可供饮用水处理用化学试剂 立即.pdf
  • DIN EN 974-2004 Chemicals used for treatment of water intended for human consumption - Phosphoric acid German version EN 974 2003《人类生活用水处理用化学试剂 磷酸》.pdf DIN EN 974-2004 Chemicals used for treatment of water intended for human consumption - Phosphoric acid German version EN 974 2003《人类生活用水处理用化学试剂 磷酸》.pdf
  • DIN EN 975-1-2011 Sawn timber - Appearance grading of hardwoods - Part 1 Oak and beech German version EN 975-1 2009 + AC 2010《锯成木材 硬木的外观等级 第1部分 橡木和榉木 德文版本EN 975-1-2009 + AC-2010》.pdf DIN EN 975-1-2011 Sawn timber - Appearance grading of hardwoods - Part 1 Oak and beech German version EN 975-1 2009 + AC 2010《锯成木材 硬木的外观等级 第1部分 橡木和榉木 德文版本EN 975-1-2009 + AC-2010》.pdf
  • DIN EN 975-2-2004 Sawn timber - Appearance grading of hardwoods - Part 2 Poplars German version EN 975-2 2004《锯材 硬木按表观分类 第2部分 白杨木》.pdf DIN EN 975-2-2004 Sawn timber - Appearance grading of hardwoods - Part 2 Poplars German version EN 975-2 2004《锯材 硬木按表观分类 第2部分 白杨木》.pdf
  • DIN EN 976-1-1997 Underground tanks of glass-reinforced plastics (GRP) - Horizontal cylindrical tanks for the non-pressure storage of liquid petroleum based fuels - Part 1 Requirem.pdf DIN EN 976-1-1997 Underground tanks of glass-reinforced plastics (GRP) - Horizontal cylindrical tanks for the non-pressure storage of liquid petroleum based fuels - Part 1 Requirem.pdf
  • DIN EN 976-2-1997 Underground tanks of glass-reinforced plastics (GRP) - Horizontal cylindrical tanks for the non pressure storage of liquid petroleum based fuels - Part 2 Transpor.pdf DIN EN 976-2-1997 Underground tanks of glass-reinforced plastics (GRP) - Horizontal cylindrical tanks for the non pressure storage of liquid petroleum based fuels - Part 2 Transpor.pdf
  • DIN EN 977-1997 Underground tanks of glass-reinforced plastics (GRP) - Method for one side exposure to fluids German version EN 977 1997《玻璃钢制地下槽罐(GRP) 单面液体负载试验方法》.pdf DIN EN 977-1997 Underground tanks of glass-reinforced plastics (GRP) - Method for one side exposure to fluids German version EN 977 1997《玻璃钢制地下槽罐(GRP) 单面液体负载试验方法》.pdf
  • DIN EN 978-1997 Underground tanks of glass-reinforced plastics (GRP) - Determination of creep factor and factor German version EN 978 1997《玻璃钢地下槽罐(GRP) 系数α和β测定》.pdf DIN EN 978-1997 Underground tanks of glass-reinforced plastics (GRP) - Determination of creep factor and factor German version EN 978 1997《玻璃钢地下槽罐(GRP) 系数α和β测定》.pdf
  • DIN EN 981-2009 Safety of machinery - System of auditory and visual danger and information signals German version EN 981 1996+A1+2008《机械安全 声光报警信号和信息信号系统》.pdf DIN EN 981-2009 Safety of machinery - System of auditory and visual danger and information signals German version EN 981 1996+A1+2008《机械安全 声光报警信号和信息信号系统》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1