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

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

1、计算机三级数据库技术-98 及答案解析(总分:100.00,做题时间:90 分钟)1.下列程序的功能是选出 5000 以下符合条件的自然数。条件是:千位数字与百位数字之和等于十位数字与个位数字之和,且千位数字与百位数字之和等于个位数字与千位数字之差的 10 倍。计算并输出满足条件的 4 位自然数的个数 cnt 及它们的和 sum。请编写函数 countValue()实现程序功能,最后调用函数writeDAT(),把结果 cnt 和 sum 输出到文件 OUT.DAT 中。 请勿改动主函数 main()和写函数 writeDAT()的内容。 试题程序 #includestdio.h int cn

2、t, sum; void writeDat(); void countValue() void main() cnt=sum=0; countValue(); printf(“满足条件的自然数的个数=%dn“, cnt); printf(“满足条件的自然数的和=%dn“, sum); writeDAT(); void writeDAT() FILE*fp; fp=fopen(“OUT.DAT“, “w“); fprintf(fp, “%dkn%dn“, cnt, sum); fclose(fp); (分数:100.00)_计算机三级数据库技术-98 答案解析(总分:100.00,做题时间:90

3、 分钟)1.下列程序的功能是选出 5000 以下符合条件的自然数。条件是:千位数字与百位数字之和等于十位数字与个位数字之和,且千位数字与百位数字之和等于个位数字与千位数字之差的 10 倍。计算并输出满足条件的 4 位自然数的个数 cnt 及它们的和 sum。请编写函数 countValue()实现程序功能,最后调用函数writeDAT(),把结果 cnt 和 sum 输出到文件 OUT.DAT 中。 请勿改动主函数 main()和写函数 writeDAT()的内容。 试题程序 #includestdio.h int cnt, sum; void writeDat(); void countVa

4、lue() void main() cnt=sum=0; countValue(); printf(“满足条件的自然数的个数=%dn“, cnt); printf(“满足条件的自然数的和=%dn“, sum); writeDAT(); void writeDAT() FILE*fp; fp=fopen(“OUT.DAT“, “w“); fprintf(fp, “%dkn%dn“, cnt, sum); fclose(fp); (分数:100.00)_正确答案:()解析:void countValue() int i; /*循环控制变量*/ int a1, a2, a3, a4; /*定义变量保

5、存 4 位数的每位数字*/ for(i=5000; i=1000; i-) /*依次取每一个数进行判断*/ a4=i/1000; /*求 4 位数的千位数字*/ a3=i%1000/100; /*求 4 位数的百位数字*/ a2=i%100/10; /*求 4 位数的十位数字*/ a1=i%10; /*求 4 位数的个位数字*/ if(a4+a3=a2+a1 /*则统计满足条件的数的个数*/ sum+=i; /*将满足条件的数求和*/ 考点 本题考查对多个整数的筛选以及统计。考查的知识点主要包括:多位整数的分解算法,逻辑表达式。 此题属于 4 位数的筛选类题型。解此题需主要解决 2 个问题:问题 1 如何取得 4 位数的各个数位数字;问题 2 如何通过条件(千位数字与百位数字之和等于个位数字与十位数字之差的 10 倍)筛选出满足条件的数并计算个数及和值;分析题意“5000 以下的自然数”,“该数存在千位数字”可知:本题的查找范围为“1000i5000”。通过问题分析,得出解此题的思路为:先求出每个数的各位数字,再根据各数位数字筛选出满足条件的数,对满足条件的数进行统计个数和累加和的运算。对于问题 1 通过算术运算取余和除法可以分解得到 4 位数的各个数位上的数字;问题 2 通过 if 条件判断语句和逻辑表达式可以实现。

展开阅读全文
相关资源
猜你喜欢
  • ITU-T Q 3313-2012 Signalling protocols and procedures relating to flow state aware QoS control in a bounded subnetwork of a next generation network (Study Group 11)《下一代网络受限子网中数据流状态.pdf ITU-T Q 3313-2012 Signalling protocols and procedures relating to flow state aware QoS control in a bounded subnetwork of a next generation network (Study Group 11)《下一代网络受限子网中数据流状态.pdf
  • ITU-T Q 3314-2012 Requirements and protocol at the interface between the mobile location management physical entity used as a proxy and the central instance of the mobile location udy .pdf ITU-T Q 3314-2012 Requirements and protocol at the interface between the mobile location management physical entity used as a proxy and the central instance of the mobile location udy .pdf
  • ITU-T Q 3315-2015 Signalling requirements for flexible network service combination on broadband network gateway (Study Group 11)《宽带网络网关上灵活的网络服务组合的信令要求(研究组11)》.pdf ITU-T Q 3315-2015 Signalling requirements for flexible network service combination on broadband network gateway (Study Group 11)《宽带网络网关上灵活的网络服务组合的信令要求(研究组11)》.pdf
  • ITU-T Q 3316-2016 Interface and signalling requirements and specification for cross stratum optimization (Study Group 11)《跨层优化的接口和信令要求和规范(研究组11)》.pdf ITU-T Q 3316-2016 Interface and signalling requirements and specification for cross stratum optimization (Study Group 11)《跨层优化的接口和信令要求和规范(研究组11)》.pdf
  • ITU-T Q 3320-2010 Architectural framework for the Q 332x series of Recommendations (Study Group 11)《Q 332x系列建议的建筑框架(研究组11)》.pdf ITU-T Q 3320-2010 Architectural framework for the Q 332x series of Recommendations (Study Group 11)《Q 332x系列建议的建筑框架(研究组11)》.pdf
  • ITU-T Q 3321 1-2010 Resource control protocol No 1 version 2 C Protocol at the Rs interface between service control entities and the policy decision physical entity (Study Group 11.pdf ITU-T Q 3321 1-2010 Resource control protocol No 1 version 2 C Protocol at the Rs interface between service control entities and the policy decision physical entity (Study Group 11.pdf
  • ITU-T Q 3401 AMD 1-2008 NGN NNI signalling profile (protocol set 1) Amendment 1 Extensions of NGN NNI signalling profile including video and data services (Study Group 11)《NGN NNI信.pdf ITU-T Q 3401 AMD 1-2008 NGN NNI signalling profile (protocol set 1) Amendment 1 Extensions of NGN NNI signalling profile including video and data services (Study Group 11)《NGN NNI信.pdf
  • ITU-T Q 3401-2007 NGN NNI signalling profile (protocol set 1) (Study Group 11)《NGN NNI发信号轮廓(协议组1)研究组11》.pdf ITU-T Q 3401-2007 NGN NNI signalling profile (protocol set 1) (Study Group 11)《NGN NNI发信号轮廓(协议组1)研究组11》.pdf
  • ITU-T Q 3402-2008 NGN UNI signalling profile (Protocol set 1) (Study Group 11)《NGN UNI信令轮廓(协议组1)》.pdf ITU-T Q 3402-2008 NGN UNI signalling profile (Protocol set 1) (Study Group 11)《NGN UNI信令轮廓(协议组1)》.pdf
  • 相关搜索

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

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