[计算机类试卷]国家三级信息管理技术机试模拟试卷31及答案与解析.doc

上传人:tireattitude366 文档编号:494957 上传时间:2018-11-28 格式:DOC 页数:3 大小:27KB
下载 相关 举报
[计算机类试卷]国家三级信息管理技术机试模拟试卷31及答案与解析.doc_第1页
第1页 / 共3页
[计算机类试卷]国家三级信息管理技术机试模拟试卷31及答案与解析.doc_第2页
第2页 / 共3页
[计算机类试卷]国家三级信息管理技术机试模拟试卷31及答案与解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级信息管理技术机试模拟试卷 31及答案与解析 一、程序设计题 1 下列程序的功能是:将大于整数 m且紧靠 m的 k个素数存入数组 xx。请编写函数 num(int m, int k, int xx)实现程序的要求,最后调用函数 readwriteDAT()把结果输出到 out31.dat文件中。 例如,若输入 17, 5,则应输出 19, 23, 29, 31, 37。 注意:部分源程序已给出。 请勿改动主函数 main()和输入输出函数 readwriteDAT()的内容。 试题程序: #include conio.h #include stdio.h void readwriteDA

2、T(); void num(int m, int k, int xx) main() int m,n,xx1000; clrscr(); printf(“nPlease enter two integers:“); scanf(“%d,%d“, num(m, n, xx); for(m=0;m n;m+) printf(“%d “,xxm); printf(“n“); readwriteDAT(); void readwriteDAT() int m, n, xx1000,i; FILE *rf,*wf; rf=fopen(“in31.dat“,“r“); wf=fopen(“out31.da

3、t“,“w“); for(i=0;i 10;i+) fscanf(rf,“%d %d“, num(m,n,xx); for(m=0;m n;m+) fprintf(wf,“%d “,xxm fprintf(wf,“n“); fclose(rf); fclose(wf); 国家三级信息管理技术机试模拟试卷 31答案与解析 一、程序设计题 1 【正确答案】 void num(int m, int k,int xx) int data=m+1; /*从大于整数 m的数开始找 */ int half, I,n=0; while(1) half=data/2; for(I=2;I =half;I+) /

4、如果该数依次除以从 2到一半的整数,余数都不是 0,则该数是素数 */ if(data%I=O) break; /*如果余数为 0,则退出循环,取下一个数判断 */ if (I half) xxn=data; n+; /*判断该数为素数后,将该数存入数组 xx中,并累计素数的个数 */ if (n =k) break; /*如果累计素数的个数超过了要求的个数,则退出循环 */ data+; /*如果累计素数的个数小于要求的个数,则继续取下一个数 */ 【试题解析】 本题考查的知识点如下: (1) 循环结构与选择结构的嵌套使用。 (2) 强行退出循环结构。 (3) 特殊运算符 “%” 的使用。 素数是除了 1和它本身之外不能被其他数整除的数 (1除外 )。在本题中,首先要结合相关数学知识找出判定一个数是否为素数的方法,从而对数据进行筛选。如果数据 a依次除以从 2到 a/2的整数,余数都不是 0,则该数是素数因为所给的数据是连续的数,而且最终所求的数据的个数一定,所以这里可以使用循环结构对数据依次筛选。同时嵌套选择结构对筛选 的数据进行不同的处理。在 a依次除以从 2到 a/2的整数的过程中,只要有一次余数为 0,则可退出这一层循环,即退出整除取余的循环,进入下一个数的判断中。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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