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

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

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

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

3、sValue();writeDat();printf(“cnt=%d/n 满足条件的平均值 pjz1=%7.2lf/n 不满足条件的平均值pjz2=%7.2lf/n“,cnt,pjz1,pjz2);void readDat()FILEfp;int i;fp=fopen(“in33dat“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE%fp;fp=fopen(“out33dat“,“w“);fprintf(fp,“%d kn%7.21f kn%721f/n“,cnt,pjz1,pjz2);fclose(fP

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

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

6、)readDat();jsValue();writeDat();printf(“cnt=%d/n 满足条件的平均值 pjz1=%7.2lf/n 不满足条件的平均值pjz2=%7.2lf/n“,cnt,pjz1,pjz2);void readDat()FILEfp;int i;fp=fopen(“in33dat“,“r“);for(i=0;i300;i+)fscanf(fp,“%d,“,fclose(fp);void writeDat()FILE%fp;fp=fopen(“out33dat“,“w“);fprintf(fp,“%d kn%7.21f kn%721f/n“,cnt,pjz1,pj

7、z2);fclose(fP);(分数:100.00)_正确答案:(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 位数的十位数字*/a1=ai%10; /*求 4 位数的个位数字*/if(a1-a4-a3-a20) /*如果个位数字减千位数字减百位数字减十位数字大于零*/

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

展开阅读全文
相关资源
猜你喜欢
  • DIN ISO 2699-2002 Diesel engines - Flange-mounted fuel injectors size S - Types 2 3 4 5 and 6 (ISO 2699 1994)《柴油发动机 法兰安装喷咀 S 规格 型号2、3、4、5和6 (ISO 2699 1994)》.pdf DIN ISO 2699-2002 Diesel engines - Flange-mounted fuel injectors size S - Types 2 3 4 5 and 6 (ISO 2699 1994)《柴油发动机 法兰安装喷咀 S 规格 型号2、3、4、5和6 (ISO 2699 1994)》.pdf
  • DIN ISO 272-1979 Fasteners Width across Flats for Hexagon Products《紧固件 六角制件的对边宽度》.pdf DIN ISO 272-1979 Fasteners Width across Flats for Hexagon Products《紧固件 六角制件的对边宽度》.pdf
  • DIN ISO 2747-1999 Vitreous and porcelain enamels - Enamelled cooking utensils - Determination of resistance to thermal shock (ISO 2747 1998)《瓷釉和搪瓷 搪瓷烹调器具 耐热冲击性能的测定》.pdf DIN ISO 2747-1999 Vitreous and porcelain enamels - Enamelled cooking utensils - Determination of resistance to thermal shock (ISO 2747 1998)《瓷釉和搪瓷 搪瓷烹调器具 耐热冲击性能的测定》.pdf
  • DIN ISO 27588-2014 Rubber vulcanized or thermoplastic - Determination of dead-load hardness using the very low rubber hardness (VLRH) scale (ISO 27588 2012)《硫化或热塑性橡胶 用非常低橡胶硬度(VLRH).pdf DIN ISO 27588-2014 Rubber vulcanized or thermoplastic - Determination of dead-load hardness using the very low rubber hardness (VLRH) scale (ISO 27588 2012)《硫化或热塑性橡胶 用非常低橡胶硬度(VLRH).pdf
  • DIN ISO 2768-1-1991 General tolerances tolerances for linear and angular dimensions without individual tolerance indications identical with ISO 2768-1 1989《通用公差 第1部分 不逐一标注公差的线性尺寸和角.pdf DIN ISO 2768-1-1991 General tolerances tolerances for linear and angular dimensions without individual tolerance indications identical with ISO 2768-1 1989《通用公差 第1部分 不逐一标注公差的线性尺寸和角.pdf
  • DIN ISO 2768-2-1991 General tolerances geometrical tolerances for features without individual tolerances indications identical with ISO 2768-2 1989《通用公差 第2部分 未标注专用公差的功能部件用形位公差 等同采用.pdf DIN ISO 2768-2-1991 General tolerances geometrical tolerances for features without individual tolerances indications identical with ISO 2768-2 1989《通用公差 第2部分 未标注专用公差的功能部件用形位公差 等同采用.pdf
  • DIN ISO 27955-2012 Road vehicles - Securing of cargo in passenger cars station wagons and multi-purpose vehicles - Requirements and test methods (ISO 27955 2010)《道路车辆 轿车 旅行车 多用途汽车货.pdf DIN ISO 27955-2012 Road vehicles - Securing of cargo in passenger cars station wagons and multi-purpose vehicles - Requirements and test methods (ISO 27955 2010)《道路车辆 轿车 旅行车 多用途汽车货.pdf
  • DIN ISO 27956-2011 Road vehicles - Securing of cargo in delivery vans - Requirements and test methods (ISO 27956 2009)《公路车辆 厢式货车的货物固定要求和试验方法(ISO 27956-2009)》.pdf DIN ISO 27956-2011 Road vehicles - Securing of cargo in delivery vans - Requirements and test methods (ISO 27956 2009)《公路车辆 厢式货车的货物固定要求和试验方法(ISO 27956-2009)》.pdf
  • DIN ISO 28000-2015 Specification for security management systems for the supply chain (ISO 28000 2007)《供应链用安全管理系统的规范(ISO 28000-2007)》.pdf DIN ISO 28000-2015 Specification for security management systems for the supply chain (ISO 28000 2007)《供应链用安全管理系统的规范(ISO 28000-2007)》.pdf
  • 相关搜索

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

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