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

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

1、三级数据库技术-543 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 PROG1.G 的功能是:寻找并输出 11 至 999 之间的数 m,它满足 m、m 2 和 m 3 均为回文数。所谓回文数是指其各位数字左右对称的整数,例如 121,676,94249 等。满足上述条件的数如 m=11,m 2 =121,m 3 =1331 皆为回文数。请考生编制函数 int JsValue(long m)实现此功能,如果是回文数,则函数返回 1,反之则返回 0。最后把结果输出到文件 out.dat 中。 请勿改动主函数 main()。 #

2、include stdio.h int jsValue(long m) main () long m; FILE *out; out=fopen(“out.dat“, “w“); /以只写的方式打开文件 out.dat,并使文件指针 out 指向此文件 /*对在 11 至 999 之间的数 m 进行扫描,调用函数 jsValue()进行判断,如果 m, m2, m3 都是回文,则把这三个数输出到屏幕上并输出到文件 out.dat 中*/ for(m=11; m1000; m+) if(jsValue(m) fprintf(out, “m=%41d,m*m=%61d, m*m*m=%81dn“,

3、 m, m*m, m*m*m); fclose (out); /关闭 out.dat 文件 (分数:100.00)_三级数据库技术-543 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 PROG1.G 的功能是:寻找并输出 11 至 999 之间的数 m,它满足 m、m 2 和 m 3 均为回文数。所谓回文数是指其各位数字左右对称的整数,例如 121,676,94249 等。满足上述条件的数如 m=11,m 2 =121,m 3 =1331 皆为回文数。请考生编制函数 int JsValue(long m)实现此功能,如果是回文

4、数,则函数返回 1,反之则返回 0。最后把结果输出到文件 out.dat 中。 请勿改动主函数 main()。 #include stdio.h int jsValue(long m) main () long m; FILE *out; out=fopen(“out.dat“, “w“); /以只写的方式打开文件 out.dat,并使文件指针 out 指向此文件 /*对在 11 至 999 之间的数 m 进行扫描,调用函数 jsValue()进行判断,如果 m, m2, m3 都是回文,则把这三个数输出到屏幕上并输出到文件 out.dat 中*/ for(m=11; m1000; m+) i

5、f(jsValue(m) fprintf(out, “m=%41d,m*m=%61d, m*m*m=%81dn“, m, m*m, m*m*m); fclose (out); /关闭 out.dat 文件 (分数:100.00)_正确答案:()解析:long i,n; i=m; n=0; /*在 while 循环体中对组成整数 i 的各位上的数字进行逆序排列*/ while(i) n=n*10+i%10; i/=10; return m=n; /如果逆序排列后的数与原数相同,则返回 1 解析 回文数字。 定义长整型变量 i、n,并分别赋给初值 m、0(m 的值等于主函数中 m 循环变量的值)。 当变量 i 的值非零时,即 m 值不为 0 时,把 n 乘以 10 加上 i 除以 10 所得的余数的和赋给变量 n,把 i除以 10 所得的商,赋给变量 i。实现对整数 i 各位上的数字进行逆序排列。 当退出 while 循环时,判断 n 是否等于 m,如果两者相等,则说明参数 m 是回文,返回 1,否则,不是回文,返回 0。

展开阅读全文
相关资源
猜你喜欢
  • DIN ISO 3917-2003 Road vehicles - Safety glazing materials - Test methods for resistance to radiation high temperature humidity fire and simulated weathering (ISO 3917 1999)《道路车辆 安.pdf DIN ISO 3917-2003 Road vehicles - Safety glazing materials - Test methods for resistance to radiation high temperature humidity fire and simulated weathering (ISO 3917 1999)《道路车辆 安.pdf
  • DIN ISO 3918-2010 Milking machine installations - Vocabulary (ISO 3918 2007)《挤奶机装置 词汇表(ISO 3918-2007)》.pdf DIN ISO 3918-2010 Milking machine installations - Vocabulary (ISO 3918 2007)《挤奶机装置 词汇表(ISO 3918-2007)》.pdf
  • DIN ISO 3919-2017 Coated abrasives - Flap wheels with shaft (ISO 3919 2005 + Amd 1 2014)《砂布 研磨页轮(ISO 3919-2005+Amd 1-2014)》.pdf DIN ISO 3919-2017 Coated abrasives - Flap wheels with shaft (ISO 3919 2005 + Amd 1 2014)《砂布 研磨页轮(ISO 3919-2005+Amd 1-2014)》.pdf
  • DIN ISO 3923-2-1987 Metallic powders determination of apparent density Scott volumeter method identical with ISO 3923 2 edition 1981《金属粉末 表观密度的测定 第2部分 斯科特(Scott)容量法》.pdf DIN ISO 3923-2-1987 Metallic powders determination of apparent density Scott volumeter method identical with ISO 3923 2 edition 1981《金属粉末 表观密度的测定 第2部分 斯科特(Scott)容量法》.pdf
  • DIN ISO 3939-1978 Fluid Power Systems and Components Multiple Lip Packing Sets Methods for Measuring Stack Heights《流体传动系统和元件 多层唇形密封组件 测量叠合高度的方法》.pdf DIN ISO 3939-1978 Fluid Power Systems and Components Multiple Lip Packing Sets Methods for Measuring Stack Heights《流体传动系统和元件 多层唇形密封组件 测量叠合高度的方法》.pdf
  • DIN ISO 3946-1986 Starches and derived products determination of the total phosphorus content spectrophotometric method identical with ISO 3946 edition 1982《淀粉及其相关制品 磷总含量的测定 分光光度法》.pdf DIN ISO 3946-1986 Starches and derived products determination of the total phosphorus content spectrophotometric method identical with ISO 3946 edition 1982《淀粉及其相关制品 磷总含量的测定 分光光度法》.pdf
  • DIN ISO 3951-1-2016 Sampling procedures for inspection by variables - Part 1 Specification for single sampling plans indexed by acceptance quality limit (AQL) for lot-by-lot inspec.pdf DIN ISO 3951-1-2016 Sampling procedures for inspection by variables - Part 1 Specification for single sampling plans indexed by acceptance quality limit (AQL) for lot-by-lot inspec.pdf
  • DIN ISO 3952-1 A1-2003 Kinematic diagrams - Graphical symbols Amendment 1 (ISO 3952-1 1981 DAM 1 2002)《运动图 图形符号 修改件 A1》.pdf DIN ISO 3952-1 A1-2003 Kinematic diagrams - Graphical symbols Amendment 1 (ISO 3952-1 1981 DAM 1 2002)《运动图 图形符号 修改件 A1》.pdf
  • DIN ISO 3952-1-1995 Simplified representation for kinematics - Part 1 Representation of motion of links identical with ISO 3952-1 1981《运动学简易表示法 第1部分 链接运动的表示法 等同采用 ISO 3952-1 1981》.pdf DIN ISO 3952-1-1995 Simplified representation for kinematics - Part 1 Representation of motion of links identical with ISO 3952-1 1981《运动学简易表示法 第1部分 链接运动的表示法 等同采用 ISO 3952-1 1981》.pdf
  • 相关搜索

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

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