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

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

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

2、hint cnt, sum;void countValue ()void main ( )cnt=sum=0;countValue ();printf(“素数的个数=%d/n“,cnt);printf(“按要求计算机得值=%d/n“, sum);writeDAT ( );writeDAT ( )FILE *fp;fp=fopen (“OUT66.DAT“, “w“);fprintf (fp, “%d/n%d/n“, cnt, sum);fclose(fp);(分数:100.00)_三级数据库技术机试-271 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:10

3、0.00)1.下列程序的功能是:计算 500800 之间素数的个数 cnt,并按所求素数的值从小到大的顺序,再计算其间隔加、减之和,即第 1个素数-第 2个素数+第 3个素数-第 4个素数+第 5个素数的值 sum。请编写函数 countValue()实现程序的要求,最后调用函数 writeDat()把结果 cnt和 sum输出到文件OUT66.DAT中。注意:部分源程序己给出。请勿改动主函数 main()和写函数 writeDAT()的内容。试题程序:includestdio.hint cnt, sum;void countValue ()void main ( )cnt=sum=0;cou

4、ntValue ();printf(“素数的个数=%d/n“,cnt);printf(“按要求计算机得值=%d/n“, sum);writeDAT ( );writeDAT ( )FILE *fp;fp=fopen (“OUT66.DAT“, “w“);fprintf (fp, “%d/n%d/n“, cnt, sum);fclose(fp);(分数:100.00)_正确答案:(void countValue() int i,j,half,yy100;for(i=500;i800;i+) half=i/2;for(j=2;j=half;j+)if(i%j=0)break; /*如果该数不是素数

5、则退出此层循环*/if(j=half) /*如果该数是素数,则将该数存入数组 yy中*/ yycnt=i;cnt+; /*统计素数的个数*/for(i=0,j=-1;icnt;i+) /*计算这些素数的间隔加、减之和*/ i=j*-1;sum+=j*yyi;)解析:解析 本题考查的知识点如下:(1)利用循环和“%”进行素数的判断。(2)间隔加、减的实现。在本题中,首先要找出判断素数的方法。若一个数 a依次除以从 2到 a/2的数所得的余数都不是 0,则这个数是素数。用此方法依次判断出从 500到 800区间内的素数。由题意可知,第 1,3,5个素数计算加法,第 2,4,6个素数计算减法。减去 1个正整数就是加上负的这个正整数,所以可以将这个正整数乘以-1 进行加法。使用循环实现求和,在奇数次的循环中,每个素数乘以 1,偶数次的循环中,素数乘以-1,就可实现间隔加、减。

展开阅读全文
相关资源
猜你喜欢
  • ASA S2 71-1983 American National Standard Guide to the Evaluation of Human Exposure to Vibration in Buildings《美国35Pinelawn Road 114 E Melville NY 机械振动标准声学协会人体照射到房屋震动可接受标准S2评估指南》.pdf ASA S2 71-1983 American National Standard Guide to the Evaluation of Human Exposure to Vibration in Buildings《美国35Pinelawn Road 114 E Melville NY 机械振动标准声学协会人体照射到房屋震动可接受标准S2评估指南》.pdf
  • ASA S2 72 PART 1 AMD 1-2010 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 1 General requirements AMENDMENT.pdf ASA S2 72 PART 1 AMD 1-2010 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 1 General requirements AMENDMENT.pdf
  • ASA S2 72 PART 1-2002 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 1 General requirements - Nationally Ad.pdf ASA S2 72 PART 1-2002 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 1 General requirements - Nationally Ad.pdf
  • ASA S2 72 PART 4 AMD 1-2010 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 4 Guidelines for the evaluation .pdf ASA S2 72 PART 4 AMD 1-2010 American National Standard Mechanical vibration and shock C Evaluation of human exposure to whole-body vibration C Part 4 Guidelines for the evaluation .pdf
  • ASA S2 72 PART 4-2003 American National Standard Mechanical Vibration and Shock C Evaluation of Human Exposure to Whole Body Vibration C Part 4 Guidelines for the Evaluation of the.pdf ASA S2 72 PART 4-2003 American National Standard Mechanical Vibration and Shock C Evaluation of Human Exposure to Whole Body Vibration C Part 4 Guidelines for the Evaluation of the.pdf
  • ASA S2 73-2014 American National Standard Mechanical Vibration and Shock C Hand-arm Vibration C Measurement and Evaluation of the Vibration Transmissibility of Gloves at the Palm o.pdf ASA S2 73-2014 American National Standard Mechanical Vibration and Shock C Hand-arm Vibration C Measurement and Evaluation of the Vibration Transmissibility of Gloves at the Palm o.pdf
  • ASA S2 73-2014 American National Standard Mechanical Vibration and Shock C Hand-arm Vibration C Measurement and Evaluation of the Vibration Transmissibility of Gloves at the Palm ot.pdf ASA S2 73-2014 American National Standard Mechanical Vibration and Shock C Hand-arm Vibration C Measurement and Evaluation of the Vibration Transmissibility of Gloves at the Palm ot.pdf
  • ASA S2 75 PART 1-2017 AMERICAN NATIONAL STANDARD Shaft Alignment Methodology Part 1 General Principles Methods Practices and Tolerances.pdf ASA S2 75 PART 1-2017 AMERICAN NATIONAL STANDARD Shaft Alignment Methodology Part 1 General Principles Methods Practices and Tolerances.pdf
  • ASA S2 75 PART 2-2017 American National Standard Shaft Alignment Methodology Part 2 Vocabulary.pdf ASA S2 75 PART 2-2017 American National Standard Shaft Alignment Methodology Part 2 Vocabulary.pdf
  • 相关搜索

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

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