[计算机类试卷]国家三级信息管理技术机试模拟试卷43及答案与解析.doc

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

1、国家三级信息管理技术机试模拟试卷 43及答案与解析 一、程序设计题 1 下列程序的功能是;寻找并输出 11至 999之间的数 m,它满足 m, m2和 m3均为回文数。所谓回文数是指其各位数字左右对称的整数,例如 121, 676, 94249等。满足上述条件的数如 m=11, m2=121, m3=1331皆为回文数。请编制函数 int jsvalue(long n)实现此功能,如果是回文数,则函数返回 1,反之则返回 0。最后把结果输出到文件 out43.dat中。 注意:部分源程序已给出。 请勿改动主函数 main()。 试题程序: #include stdio.h int jsValu

2、e(long n) main() long m; FILE *out; out=fopen(“out43.dat“,“w“); for(m=11;m 1000;m+) if(jsValue(m) fprintf(out,“m=%4ld,m*m=%6ld,m*m*m=%8ldn“,m,m*m,m*m*m); fclose(out); 国家三级信息管理技术机试模拟试卷 43答案与解析 一、程序设计题 1 【正确答案】 int jsValue(long n) int i, str1, half; char xy20; ltoa(n, xy, 10); /*将长整数 n转换成与其等价的字符串存入 xy

3、指向的字符串中,输出串为十进制 */ str1=strlen(xy); /*求字符串的长度 */ half=str1/2; for(i=0; i half; i+) if(xyi!=xy-str1)break; /*判断字符串是否左右对称 */ if(i =half) return 1; /*如果字符串是回文,则返回 1*/ else return 0; /*否则返回 0*/ 【试题解析】 本题考查的知识点如下; (1)将整型变量转换成字符串。 (2)字符串长度的确定和循环的使用。 (3)字符串是否对称的判断。 回文数是指其各位数字左右均对称的整数,因为给出的 数的位数不确定,所以不采用将各位上的数字转变成单独的数再比较的方法。这里使用函数char*ltoa(long num,char*str,int radix),其功能是将长整数 num转换成与其等价的字符串存入 str指向的字符串中,输出串的进制由 radix决定。将整数转变成字符串后,判断字符串是否左右对称。求得字符串长度后设置两个变量,一个从字符串的头开始向后移动,一个从字符串的倒数第二个元素开始向前移动,直到移至数组的中间元素。若两者所决定的数组元素均相等,则字符串左右对称。

展开阅读全文
相关资源
猜你喜欢
  • STAS SR ISO 5855-3-1994 Aerospace - MJ threds - Part 3 Limit dimensions for fittings for fluid systems《航空航天 MJ螺纹 第3部分:液体系统管接头螺纹系统的极限尺寸》.pdf STAS SR ISO 5855-3-1994 Aerospace - MJ threds - Part 3 Limit dimensions for fittings for fluid systems《航空航天 MJ螺纹 第3部分:液体系统管接头螺纹系统的极限尺寸》.pdf
  • STAS SR ISO 5884-1996 Aerospace - Fluid systems and components - Methods for system sampling and measuring the soiid partide contamination of hydraulic fluids《航空航天 液压系统和组件 液压流体固体微粒.pdf STAS SR ISO 5884-1996 Aerospace - Fluid systems and components - Methods for system sampling and measuring the soiid partide contamination of hydraulic fluids《航空航天 液压系统和组件 液压流体固体微粒.pdf
  • STAS SR ISO 5889-1983 Manganese ores and concentrates-Determination of atuminium copper lead and zinc contents-Flame atomic absorbtion spectrometric method《锰矿石和锰精矿 铝的测定铜、铅、锌含量 火焰原子.pdf STAS SR ISO 5889-1983 Manganese ores and concentrates-Determination of atuminium copper lead and zinc contents-Flame atomic absorbtion spectrometric method《锰矿石和锰精矿 铝的测定铜、铅、锌含量 火焰原子.pdf
  • STAS SR ISO 5890-1981 Manganese ores and concentrates- Determination of silicon content- Gravimetric method《锰矿石和锰精矿 硅含量的测定 重量法 》.pdf STAS SR ISO 5890-1981 Manganese ores and concentrates- Determination of silicon content- Gravimetric method《锰矿石和锰精矿 硅含量的测定 重量法 》.pdf
  • STAS SR ISO 5897-1995 Road vehides - Rear-window demisting system for passenger cars - Test method《道路车辆 轿车后车窗除雾系统 试验方法 》.pdf STAS SR ISO 5897-1995 Road vehides - Rear-window demisting system for passenger cars - Test method《道路车辆 轿车后车窗除雾系统 试验方法 》.pdf
  • STAS SR ISO 5922-1995 Malleable cast iron《可锻铸铁 》.pdf STAS SR ISO 5922-1995 Malleable cast iron《可锻铸铁 》.pdf
  • STAS SR ISO 6009-1995 Hypodermic needles for single use - Colour coding for identification《一次性皮下注射针头 识别彩色编码 》.pdf STAS SR ISO 6009-1995 Hypodermic needles for single use - Colour coding for identification《一次性皮下注射针头 识别彩色编码 》.pdf
  • STAS SR ISO 6015-1994 Earth moving machinery - Hydraulic excavators - Methods of measuring too forces《运土机械 液压挖掘机 测量工具力方法 》.pdf STAS SR ISO 6015-1994 Earth moving machinery - Hydraulic excavators - Methods of measuring too forces《运土机械 液压挖掘机 测量工具力方法 》.pdf
  • STAS SR ISO 6018-1995 Orthopaedic implants General requirements for marking packaging and labelling《整形外科移植 标识,包装和标签一般要求》.pdf STAS SR ISO 6018-1995 Orthopaedic implants General requirements for marking packaging and labelling《整形外科移植 标识,包装和标签一般要求》.pdf
  • 相关搜索

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

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