[计算机类试卷]国家三级(数据库技术)机试模拟试卷64及答案与解析.doc

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

1、国家三级(数据库技术)机试模拟试卷 64及答案与解析 一、程序设计题 1 下列程序的功能是:找出所有 100以内 (含 100)满足 I, I+4, I+10都是素数的整数 I(1+10也是在 100以内 )的个数 cnt,以及这些 I之和 sum。请编制函数countValue()实现程序要求,最后调用函数 writeDAT()把结果 cnt和 sum输出到文件 out64.dat中 (数值 1不是素数 )。 注意:部分源程序已给出。 请勿改动主函数 main()和输出数据函数 writeDAT()的内容。 试题程序: #include stdio.h int cnt, sum; int i

2、sPrime(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 ( “满足条件的整数的个数 =%dn“, cnt); printf ( “满足条件的整数的和值 =%dn“, sum); writeDAT ( ); writeDAT ( ) FILE *fp; fp=fopen(“out64.dat“,“w“); fp

3、rintf(fp,“%dn%dn“,cnt,sum); fclose(fp); 国家三级(数据库技术)机试模拟试卷 64答案与解析 一、程序设计题 1 【正确答案】 void countValue() int i, count=0, xx30; int j, k, m; cnt=0; sum=0; for(i=2; i 90; i+) /*找数的范围为 100以内 */ if(isPrime(i) /*如果该数为素数,则将它存入数组 xx中,并统计个数 */ xxcount=i; count+; for(i=0; i count; i+) /*如果数组 xx中的素数加 4和加 10得到的数仍为

4、素数*/ 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是素数必须同时满足,所以两个条件间用 “与 ”运算。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 8486-2-2007 Bonded abrasives Determination and designation of grain size distribution Microgrits F230 to F2000《粘合磨料 粒度分布的测定和标记 F230到F2000微磨粉》.pdf BS ISO 8486-2-2007 Bonded abrasives Determination and designation of grain size distribution Microgrits F230 to F2000《粘合磨料 粒度分布的测定和标记 F230到F2000微磨粉》.pdf
  • BS ISO IEC 19798-2017 Information technology Office equipment Method for the determination of toner cartridge yield for colour printers and multifunction devices that cont.pdf BS ISO IEC 19798-2017 Information technology Office equipment Method for the determination of toner cartridge yield for colour printers and multifunction devices that cont.pdf
  • BS ISO IEC 19944-2017 Information technology Cloud computing Cloud services and devices Data flow data categories and data use《信息技术 云计算 云服务和设备 数据流、数据类别和数据使用》.pdf BS ISO IEC 19944-2017 Information technology Cloud computing Cloud services and devices Data flow data categories and data use《信息技术 云计算 云服务和设备 数据流、数据类别和数据使用》.pdf
  • BS PAS 5308-2-2009 5625 Control and instrumentation cables Part 2 Specification for PVC insulated cables《控制和仪表电缆 第2部分 PVC绝缘电缆规范》.pdf BS PAS 5308-2-2009 5625 Control and instrumentation cables Part 2 Specification for PVC insulated cables《控制和仪表电缆 第2部分 PVC绝缘电缆规范》.pdf
  • BS PD IEC TS 60870-5-601-2015 Telecontrol equipment and systems Transmission protocols Conformance test cases for the IEC 60870-5-101 companion standard《遥控设备和系统 IEC 60870-.pdf BS PD IEC TS 60870-5-601-2015 Telecontrol equipment and systems Transmission protocols Conformance test cases for the IEC 60870-5-101 companion standard《遥控设备和系统 IEC 60870-.pdf
  • BS PD ISO IEC GUIDE 51-2014 Safety aspects Guidelines for their inclusion in standards《安全方面 将其列入标准的指南》.pdf BS PD ISO IEC GUIDE 51-2014 Safety aspects Guidelines for their inclusion in standards《安全方面 将其列入标准的指南》.pdf
  • BS PD ISO IEC GUIDE 71-2014 Guide for addressing accessibility in standards《标准中无障碍解决指南》.pdf BS PD ISO IEC GUIDE 71-2014 Guide for addressing accessibility in standards《标准中无障碍解决指南》.pdf
  • BS PD ISO IEC TR 10182-2016 Information technology Programming languages their environments and system software interfaces Guidelines for language bindings《信息技术 编程语言 语言环境及系统软件接口 语言汇集指南》.pdf BS PD ISO IEC TR 10182-2016 Information technology Programming languages their environments and system software interfaces Guidelines for language bindings《信息技术 编程语言 语言环境及系统软件接口 语言汇集指南》.pdf
  • BS PD ISO IEC TR 11801-9903-2015 Information technology Generic cabling systems for customer premises Matrix modelling of channels and links《信息技术 用户建筑群通用布线系统 频道和链接的矩阵模型》.pdf BS PD ISO IEC TR 11801-9903-2015 Information technology Generic cabling systems for customer premises Matrix modelling of channels and links《信息技术 用户建筑群通用布线系统 频道和链接的矩阵模型》.pdf
  • 相关搜索

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

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