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

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

1、三级信息管理技术机试-243 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:计算 500800 之间素数的个数 cnt,并按所求素数存入数组 yy 中,再计算其间隔加、减之和,即第 1 个素数-第 2 个素数+第 3 个素数-第 4 个素数+第 5 个素数的值 sum。请编写函数countValue()实现程序的要求,最后调用函数 writeDat()把结果 cnt 和 sum 输出到文件 OUT89.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()和写函数 writeDAT()的内容。试题程序:#inc

2、lude stdio.hint cnt,sum;void writeDAT();void countValue()void main()cnt=sum=0;countValue();printf(“素数的个数=% d/n“,cnt);printf(“按要求计算的值=% d/n“,sum);writeDAT();void writeDAT()FILE * fp;fp=fopen(“OUT89.DAT“,“w“);fprintf(fp,“ % d/n% d/n“,cnt,sum);fclose(fp);(分数:100.00)_三级信息管理技术机试-243 答案解析(总分:100.00,做题时间:9

3、0 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:计算 500800 之间素数的个数 cnt,并按所求素数存入数组 yy 中,再计算其间隔加、减之和,即第 1 个素数-第 2 个素数+第 3 个素数-第 4 个素数+第 5 个素数的值 sum。请编写函数countValue()实现程序的要求,最后调用函数 writeDat()把结果 cnt 和 sum 输出到文件 OUT89.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()和写函数 writeDAT()的内容。试题程序:#include stdio.hint cnt,sum;void writeDAT

4、);void countValue()void main()cnt=sum=0;countValue();printf(“素数的个数=% d/n“,cnt);printf(“按要求计算的值=% d/n“,sum);writeDAT();void writeDAT()FILE * fp;fp=fopen(“OUT89.DAT“,“w“);fprintf(fp,“ % d/n% d/n“,cnt,sum);fclose(fp);(分数:100.00)_正确答案:(void countValue()int i,j; /*定义循环控制变量*/int half; /*判断素数时所需值的存储变量*/in

5、t xx100; /*定义整型数组,用来保存素数*/for(i=500;i800;i + +) /*在这个范围内进行筛选*/half=i/2;for(j=2;j=half;j + +) /*判断是否为素数*/if(i%j=0)break; /*如果该数不是素数,则退出此层循环*/if(j=half) /*如果该数是素数,则将该数存入数组 yy 中*/xxcnt=i;cnt + +; /*统计素数的个数*/for(i=0,j=-1;icnt;i + +) /*计算这些素数的间隔加、减之和*/j*=-1; /*用变量 j 来控制间隔的加减号*/sum+=j*xxi;)解析:解析 在本题中,首先要找出判断素数的方法。若一个数 a 依次除以从 2 到 a/2 的数所得的余数都不是 0,则这个数是素数。用此方法依次筛选出从 500-800 区间内的素数。然后,将满足条件的数存入数组 xx 中,并统计素数的个数。最后,用一个 for 循环和变量 j 来实现间隔加、减,最终计算出结果。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 24345-2012 Resilient floor coverings - Determination of peel resistance (ISO 24345 2006) German version EN ISO 24345 2012《弹性覆地材料 抗裂强度测定》.pdf DIN EN ISO 24345-2012 Resilient floor coverings - Determination of peel resistance (ISO 24345 2006) German version EN ISO 24345 2012《弹性覆地材料 抗裂强度测定》.pdf
  • DIN EN ISO 24346-2012 Resilient floor coverings - Determination of overall thickness (ISO 24346 2006) German version EN ISO 24346 2012《弹性覆地材料 整体厚度测定》.pdf DIN EN ISO 24346-2012 Resilient floor coverings - Determination of overall thickness (ISO 24346 2006) German version EN ISO 24346 2012《弹性覆地材料 整体厚度测定》.pdf
  • DIN EN ISO 24373-2009 Welding consumables - Solid wires and rods for fusion welding of copper and copper alloys - Classification (ISO 24373 2008) English version of DIN EN ISO 2437.pdf DIN EN ISO 24373-2009 Welding consumables - Solid wires and rods for fusion welding of copper and copper alloys - Classification (ISO 24373 2008) English version of DIN EN ISO 2437.pdf
  • DIN EN ISO 24415-1-2009 Tips for assistive products for walking - Requirements and test methods - Part 1 Friction of tips (ISO 24415-1 2009) English version of DIN EN ISO 24415-1 2.pdf DIN EN ISO 24415-1-2009 Tips for assistive products for walking - Requirements and test methods - Part 1 Friction of tips (ISO 24415-1 2009) English version of DIN EN ISO 24415-1 2.pdf
  • DIN EN ISO 24431-2017 Gas cylinders - Seamless welded and composite cylinders for compressed and liquefied gases (excluding acetylene) - Inspection at time of filling (ISO 24431 20.pdf DIN EN ISO 24431-2017 Gas cylinders - Seamless welded and composite cylinders for compressed and liquefied gases (excluding acetylene) - Inspection at time of filling (ISO 24431 20.pdf
  • DIN EN ISO 24442-2012 Cosmetics - Sun protection test methods - In vivo determination of sunscreen UVA protection (ISO 24442 2011) German version EN ISO 24442 2011《化妆品 防晒试验方法 遮光剂长波.pdf DIN EN ISO 24442-2012 Cosmetics - Sun protection test methods - In vivo determination of sunscreen UVA protection (ISO 24442 2011) German version EN ISO 24442 2011《化妆品 防晒试验方法 遮光剂长波.pdf
  • DIN EN ISO 24443-2013 Determination of sunscreen UVA photoprotection in vitro (ISO 24443 2012) German version EN ISO 24443 2012《体外紫外线A辐射(UVA)光损伤防护防晒霜含量测定(ISO 24443-2012) 德文版本EN ISO.pdf DIN EN ISO 24443-2013 Determination of sunscreen UVA photoprotection in vitro (ISO 24443 2012) German version EN ISO 24443 2012《体外紫外线A辐射(UVA)光损伤防护防晒霜含量测定(ISO 24443-2012) 德文版本EN ISO.pdf
  • DIN EN ISO 24444-2011 Cosmetics - Sun protection test methods - In vivo determination of the sun protection factor (SPF) (ISO 24444 2010) German version EN ISO 24444 2010《化妆品 防晒试验方.pdf DIN EN ISO 24444-2011 Cosmetics - Sun protection test methods - In vivo determination of the sun protection factor (SPF) (ISO 24444 2010) German version EN ISO 24444 2010《化妆品 防晒试验方.pdf
  • DIN EN ISO 24450-2006 Laboratory glassware - Wide-necked boiling flasks (ISO 24450 2005) English version of DIN EN ISO 24450 2006-02《实验室玻璃器皿 广口长颈烧瓶(ISO 24450-2005) 德文版本 EN ISO 2445.pdf DIN EN ISO 24450-2006 Laboratory glassware - Wide-necked boiling flasks (ISO 24450 2005) English version of DIN EN ISO 24450 2006-02《实验室玻璃器皿 广口长颈烧瓶(ISO 24450-2005) 德文版本 EN ISO 2445.pdf
  • 相关搜索

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

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