【计算机类职业资格】全国计算机等级考试三级网络技术机试真题2008年9月及答案解析.doc

上传人:postpastor181 文档编号:1329541 上传时间:2019-10-17 格式:DOC 页数:3 大小:27.50KB
下载 相关 举报
【计算机类职业资格】全国计算机等级考试三级网络技术机试真题2008年9月及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】全国计算机等级考试三级网络技术机试真题2008年9月及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】全国计算机等级考试三级网络技术机试真题2008年9月及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、全国计算机等级考试三级网络技术机试真题 2008 年 9 月及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编写一个函数 jS Value(int m, int k, int xx),该函数的功能是:将小于整数 m 且紧靠 m 的 k个素数存入数组 xx 并传回。调用函数 writeDat()读取 10 组数据,分别得出结果且把结果输出到文件out.dat 中。注意:部分源程序给出如下。例如:若输入“17,5”,则应输出“13,11,7,5,3”。请勿改动主函数 main()和输出数据函数 readwriteDat()的内容。试题源程序#

2、includeconio.h#includestdio.hvoid readwriteDat();void num(int m, int k, int xx)main()int m, n, xx1000;System(“cls“);printf(“/nPlease enter two integers:“);Scanf(“%d%d“, num(m,n,xx);for(m=0;mn;m+)printf(“%d“,xxm);printf(“/n“);readwriteDat();void readwriteDat()int m,n,xx1000,i;FILE *rf,*wf;rf=fopen(“i

3、n.dat“,“r“);wf=fopen(“out.dat“,“w“);for(i=0;i10;i+)Scanf(rf,“%d%d“,for(m=0;mn;m+) fprintf(wf,“%d“,xxm);fprintf(wf,“/n“);fclose(rf);fclose(wf);(分数:100.00)_全国计算机等级考试三级网络技术机试真题 2008 年 9 月答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编写一个函数 jS Value(int m, int k, int xx),该函数的功能是:将小于整数 m 且紧靠 m 的 k个素

4、数存入数组 xx 并传回。调用函数 writeDat()读取 10 组数据,分别得出结果且把结果输出到文件out.dat 中。注意:部分源程序给出如下。例如:若输入“17,5”,则应输出“13,11,7,5,3”。请勿改动主函数 main()和输出数据函数 readwriteDat()的内容。试题源程序#includeconio.h#includestdio.hvoid readwriteDat();void num(int m, int k, int xx)main()int m, n, xx1000;System(“cls“);printf(“/nPlease enter two inte

5、gers:“);Scanf(“%d%d“, num(m,n,xx);for(m=0;mn;m+)printf(“%d“,xxm);printf(“/n“);readwriteDat();void readwriteDat()int m,n,xx1000,i;FILE *rf,*wf;rf=fopen(“in.dat“,“r“);wf=fopen(“out.dat“,“w“);for(i=0;i10;i+)Scanf(rf,“%d%d“,for(m=0;mn;m+) fprintf(wf,“%d“,xxm);fprintf(wf,“/n“);fclose(rf);fclose(wf);(分数:1

6、00.00)_正确答案:(void num(int m, int k, int xx)int i,j,n;for(n=m-1,i=0;ik;n-) /*该循环用了 2 个循环变量,n 用来跟踪 m 之前的数,所以每趟减 1,i 用来计算找到素数的个数,所以该循环结束的条件为 i 等于 k*/for(j=2;j=n/2;j+) /*该循环用于判断 n 是否是素数*/if(n%j=0)break;if(jn/2)xxi+=n; /*找到一个素数,先存入 xxi,然后 i 值增 1*/)解析:解析本题主要考查的是素数及其计算问题。用 for 循环来跟踪 m 之前的 k 个素数,对于 m 之后的数 n,判断其是否为素数,若是则将其赋值给 xxi,同时变量 i 增 1。变量 i 的取值范围为 0 到 k-1,用来控制 k 个素数被存入数组 xx。判断 n 是否为素数,只要内嵌一个 for 循环,使循环变量 j 的取值范围为 2 到 n 的一半。判断 n 是否能整除 j,如果有一个能整除,则跳出内层 for 循环时 jn/2,表示 n 不是素数,否则内层 for 循环结束的条件为 jn/2,表示 n 为素数。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 15316-4-8-2017 Energy performance of buildings Method for calculation of system energy requirements and system efficiencies Space heating generation systems air heating and o .pdf BS EN 15316-4-8-2017 Energy performance of buildings Method for calculation of system energy requirements and system efficiencies Space heating generation systems air heating and o .pdf
  • BS EN 15316-5-2017 Energy performance of buildings Method for calculation of system energy requirements and system efficiencies Space heating and DHW storage systems (not cooling) .pdf BS EN 15316-5-2017 Energy performance of buildings Method for calculation of system energy requirements and system efficiencies Space heating and DHW storage systems (not cooling) .pdf
  • BS EN 15317-2013 Non-destructive testing Ultrasonic testing Characterization and verification of ultrasonic thickness measuring equipment《无损检测 超声波检测 超声波测厚设备的特征和验证》.pdf BS EN 15317-2013 Non-destructive testing Ultrasonic testing Characterization and verification of ultrasonic thickness measuring equipment《无损检测 超声波检测 超声波测厚设备的特征和验证》.pdf
  • BS EN 15318-2007 Design and application of gypsum blocks《石膏块的设计和应用》.pdf BS EN 15318-2007 Design and application of gypsum blocks《石膏块的设计和应用》.pdf
  • BS EN 15319-2007 General principles of design of fibrous (gypsum) plaster works《纤维(石膏)抹灰层设计的一般原则》.pdf BS EN 15319-2007 General principles of design of fibrous (gypsum) plaster works《纤维(石膏)抹灰层设计的一般原则》.pdf
  • BS EN 15320-2007 Identification card systems - Surface transport applications - Interoperable public transport applications - Framework《识别卡系统 表面传输设备 可交替使用的公共传输设备 框架》.pdf BS EN 15320-2007 Identification card systems - Surface transport applications - Interoperable public transport applications - Framework《识别卡系统 表面传输设备 可交替使用的公共传输设备 框架》.pdf
  • BS EN 15322-2013 Bitumen and bituminous binders Framework for specifying cut-back and fluxed bituminous binders《沥青和沥青粘合剂 稀释和软制沥青粘合剂的规定框架》.pdf BS EN 15322-2013 Bitumen and bituminous binders Framework for specifying cut-back and fluxed bituminous binders《沥青和沥青粘合剂 稀释和软制沥青粘合剂的规定框架》.pdf
  • BS EN 15323-2007 Bitumen and bituminous binders - Accelerated long-term ageing conditioning by the rotating cylinder method (RCAT)《沥青和沥青粘合剂 用旋转柱体法(RCAT)加速长期老化 调节》.pdf BS EN 15323-2007 Bitumen and bituminous binders - Accelerated long-term ageing conditioning by the rotating cylinder method (RCAT)《沥青和沥青粘合剂 用旋转柱体法(RCAT)加速长期老化 调节》.pdf
  • BS EN 15329-2015 Railway applications Braking Brake block holder and brake shoe key for railway vehicles《轨道交通 制动 轨道车辆用刹车块夹具和制动蹄片》.pdf BS EN 15329-2015 Railway applications Braking Brake block holder and brake shoe key for railway vehicles《轨道交通 制动 轨道车辆用刹车块夹具和制动蹄片》.pdf
  • 相关搜索

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

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