【计算机类职业资格】三级数据库技术机试-273及答案解析.doc

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

1、三级数据库技术机试-273 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:找出所有 100 以内(含 100)满足 I,I+4,I+10 都是素数的整数 I(1+10 也是在 100以内)的个数 cnt,以及这些 I 之和 sum。请编制函数 countValue()实现程序要求,最后调用函数writeDAT()把结果 cnt 和 sum 输出到文件 out64.dat 中(数值 1 不是素数)。注意:部分源程序已给出。请勿改动主函数 main()和输出数据函数 writeDAT()的内容。试题程序:#includest

2、dio.hint cnt, sum;int isPrime(int number)int i,tag=1;if (number=1)return 0;for(i=2;tag i+)if(number%i=0) tag=0;return tag;void countValue ( )void main( )cnt=sum=0;countValue ( );printf ( “满足条件的整数的个数=%d/n“, cnt);printf ( “满足条件的整数的和值=%d/n“, sum);writeDAT ( );writeDAT ( )FILE *fp;fp=fopen(“out64.dat“,“

3、w“);fprintf(fp,“%d/n%d/n“,cnt,sum);fclose(fp);(分数:100.00)_三级数据库技术机试-273 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:找出所有 100 以内(含 100)满足 I,I+4,I+10 都是素数的整数 I(1+10 也是在 100以内)的个数 cnt,以及这些 I 之和 sum。请编制函数 countValue()实现程序要求,最后调用函数writeDAT()把结果 cnt 和 sum 输出到文件 out64.dat 中(数值 1 不是素数)。注意:部分源

4、程序已给出。请勿改动主函数 main()和输出数据函数 writeDAT()的内容。试题程序:#includestdio.hint cnt, sum;int isPrime(int number)int i,tag=1;if (number=1)return 0;for(i=2;tag i+)if(number%i=0) tag=0;return tag;void countValue ( )void main( )cnt=sum=0;countValue ( );printf ( “满足条件的整数的个数=%d/n“, cnt);printf ( “满足条件的整数的和值=%d/n“, sum)

5、writeDAT ( );writeDAT ( )FILE *fp;fp=fopen(“out64.dat“,“w“);fprintf(fp,“%d/n%d/n“,cnt,sum);fclose(fp);(分数:100.00)_正确答案:(void countValue()int i,count=0,xx30;int j,k,m;cnt=0;sum=0;for(i=2;i90;i+) /*找数的范围为 100 以内*/if(isPrime(i) /*如果该数为素数,则将它存入数组 xx 中,并统计个数*/xxcount=i;count+;for(i=0;icount;i+) /*如果数组 x

6、x 中的素数加 4 和加 10 得到的数仍为素数*/if(isPrime(xxi+4)&isPrime(xxi+10)cnt+; /*统计满足条件的数的个数*/sum+=xxi; /*将满足条件的数组 xx 中的数求和*/)解析:解析 本题考查的知识点如下:(1)循环结构与判断结构的嵌套使用。(2)判断结构中多个条件的布尔运算。题中要求判断在 100 以内,i,i+4,i+10 都是素数的个数。因为 i+10 也必须在 100 以内,1 不是素数,我们可以从 2 开始判断到 89 即可(90 是偶数,明显不是素数)。可以先找出 2 到 89 之间素数的个数,再判断这些素数加 4 和加 10 后是否还是素数。加 4 是素数与加 10 是素数必须同时满足,所以两个条件间用“与”运算。

展开阅读全文
相关资源
猜你喜欢
  • NBN X 03-003-1985 8750 Sampling procedures and tables for inspection by attributes《为检测而采用的按属性抽样的程序和步骤》.pdf NBN X 03-003-1985 8750 Sampling procedures and tables for inspection by attributes《为检测而采用的按属性抽样的程序和步骤》.pdf
  • NBN X 03-004-1985 7500 Statistical interpretation of data- Determination of a statistical tolerance interval 《数据的统计描述 确定统计容许空间》.pdf NBN X 03-004-1985 7500 Statistical interpretation of data- Determination of a statistical tolerance interval 《数据的统计描述 确定统计容许空间》.pdf
  • NBN X 03-005-1985 6250 COMPARAISON DE DEUX MOYENNES DANS LE CAS D-OBSERVATIONS APPARIEES《统计数据的解释 两种手段的情况下配对意见》.pdf NBN X 03-005-1985 6250 COMPARAISON DE DEUX MOYENNES DANS LE CAS D-OBSERVATIONS APPARIEES《统计数据的解释 两种手段的情况下配对意见》.pdf
  • NBN X 03-006-1985 5000 Statistical interpretation of data - Power of tests relating to means and varianc《统计数据的解释 效率测试手段和差异》.pdf NBN X 03-006-1985 5000 Statistical interpretation of data - Power of tests relating to means and varianc《统计数据的解释 效率测试手段和差异》.pdf
  • NBN X 03-007-1985 3750 Statistics - Vocabulary and symbols 《统计表 词汇和符号》.pdf NBN X 03-007-1985 3750 Statistics - Vocabulary and symbols 《统计表 词汇和符号》.pdf
  • NBN X 03-008-1985 9375 Sampling procedures and charts for inspection by variables for percent detective《为检测而采取的按百分比变化抽样的程序和图表》.pdf NBN X 03-008-1985 9375 Sampling procedures and charts for inspection by variables for percent detective《为检测而采取的按百分比变化抽样的程序和图表》.pdf
  • NBN X 03-009-1988 2500 Precision of tests methods - Détermination of repeatabi1ity and reproductibi1ity for a standard test method by inter-laboratory tests《测试方法的精确性 通过在多个实验室进行测试来确.pdf NBN X 03-009-1988 2500 Precision of tests methods - Détermination of repeatabi1ity and reproductibi1ity for a standard test method by inter-laboratory tests《测试方法的精确性 通过在多个实验室进行测试来确.pdf
  • NBN X 04-002-1989 6875 French terminology - Lists of terms for science technology and business with lexical and syntactical caveats《法语术语学 带有词汇和语法标注的关于科学,技术,商业术语的目录 n》.pdf NBN X 04-002-1989 6875 French terminology - Lists of terms for science technology and business with lexical and syntactical caveats《法语术语学 带有词汇和语法标注的关于科学,技术,商业术语的目录 n》.pdf
  • NBN X 04-003-1988 0625 General terms and their definitions concerning standardization and related activities《关于标准化和相关的活动的总论和定义 n》.pdf NBN X 04-003-1988 0625 General terms and their definitions concerning standardization and related activities《关于标准化和相关的活动的总论和定义 n》.pdf
  • 相关搜索

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

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