【计算机类职业资格】三级网络技术-84及答案解析.doc

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

1、三级网络技术-84 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)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

2、stdio.h int jsValue(long n) main ( ) long m; FILE *out; out=fopen (“out43.dat“, “w“); for (m=11;m1000;m+) if(jsValue(m) fprintf (out, “m=%41d, m*m=%61d, m*m*m=%81d/n“, m, m*m, m*m*m); fclose (out); (分数:100.00)_三级网络技术-84 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:寻找并输出 11 至 999 之间的数 m

3、它满足 m,m2 和 m3 均为回文数。所谓回文数是指其各位数字左右对称的整数,例如 121,676,94249 等。满足上述条件的数如 m=11,m2=121,m3=1331皆为回文数。请编制函数 int jsValue(long n)实现此功能,如果是回文数,则函数返回 1,反之则返回0。最后把结果输出到文件 out43.dat 中。 注意:部分源程序已给出。 请勿改动主函数 main()。 #includestdio.h int jsValue(long n) main ( ) long m; FILE *out; out=fopen (“out43.dat“, “w“); for (

4、m=11;m1000;m+) if(jsValue(m) fprintf (out, “m=%41d, m*m=%61d, m*m*m=%81d/n“, m, m*m, m*m*m); fclose (out); (分数:100.00)_正确答案:()解析:int jsValue(long n) int i, strl,half; char xy20; ltoa (n,xy, 10); /*将长整数 n 转换成与其等价的字符串存入 xy 指向的字符串中,输出串为十进制*/ strl=strlen(xy); /*求字符串的长度*/ half=strl/2; for (i=0; ihalf; i+

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

展开阅读全文
相关资源
猜你喜欢
  • NF A06-655-1993 Chemical analysis of titanium and titanium alloys Determination of silicon content Gravimetric method 《钛及钛合金的化学分析 硅含量测定 重量分析法》.pdf NF A06-655-1993 Chemical analysis of titanium and titanium alloys Determination of silicon content Gravimetric method 《钛及钛合金的化学分析 硅含量测定 重量分析法》.pdf
  • NF A06-656-1993 Chemical analysis of titanium alloys Determination of vanadium content in Ti-AI-V alloy Titrimetric method 《钛合金的化学分析 TI-AI-V合金中钒含量的测定 滴定法》.pdf NF A06-656-1993 Chemical analysis of titanium alloys Determination of vanadium content in Ti-AI-V alloy Titrimetric method 《钛合金的化学分析 TI-AI-V合金中钒含量的测定 滴定法》.pdf
  • NF A06-657-1993 Chemical analysis of titanium and titanium alloys Determination of zirconium content in Ti-AI-ZR alloy Gravimetric method with bromomandelic acid 《钛及钛合金的化学分析 在TI-AI.pdf NF A06-657-1993 Chemical analysis of titanium and titanium alloys Determination of zirconium content in Ti-AI-ZR alloy Gravimetric method with bromomandelic acid 《钛及钛合金的化学分析 在TI-AI.pdf
  • NF A06-701-1967 Chemical analysis of copper and copper alloys Dissolving electrolytic determination of copper lead separation 《铜和铜合金的化学分析 溶解 铜的电解测定 铅的分离》.pdf NF A06-701-1967 Chemical analysis of copper and copper alloys Dissolving electrolytic determination of copper lead separation 《铜和铜合金的化学分析 溶解 铜的电解测定 铅的分离》.pdf
  • NF A06-707-1967 Chemical analysis of copper and its alloys Electrolytic determination of lead 《铜和铜合金化学分析 铅含量电解测定》.pdf NF A06-707-1967 Chemical analysis of copper and its alloys Electrolytic determination of lead 《铜和铜合金化学分析 铅含量电解测定》.pdf
  • NF A06-708-1969 CHEMICAL ANALYSIS OF COPPER AND ITS ALLOYS POLAROGRPAHIC DETERMINATION OF LEAD 《铜和铜合金的化学分析 铅的极谱法测定》.pdf NF A06-708-1969 CHEMICAL ANALYSIS OF COPPER AND ITS ALLOYS POLAROGRPAHIC DETERMINATION OF LEAD 《铜和铜合金的化学分析 铅的极谱法测定》.pdf
  • NF A06-709-1986 Copper and copper alloys Determination of antimony content Rhodamine B spectrometric method 《铜和铜合金 锑含量的测定 若丹明B(Rhondamine B)光谱法》.pdf NF A06-709-1986 Copper and copper alloys Determination of antimony content Rhodamine B spectrometric method 《铜和铜合金 锑含量的测定 若丹明B(Rhondamine B)光谱法》.pdf
  • NF A06-710-1987 Chemical analysis of copper and copper alloys Determination of nickel content Molecular absorption spectrophotometric method 《铜和铜合金的化学分析 镍含量的测定 分子吸收分光光度计法》.pdf NF A06-710-1987 Chemical analysis of copper and copper alloys Determination of nickel content Molecular absorption spectrophotometric method 《铜和铜合金的化学分析 镍含量的测定 分子吸收分光光度计法》.pdf
  • NF A06-711-1987 Chemical analysis of copper and copper alloys Determination of iron content Molecular absorption spectrophotometric method 《铜和铜合金的化学分析 铁含量的测定 分子吸收分光光度计法》.pdf NF A06-711-1987 Chemical analysis of copper and copper alloys Determination of iron content Molecular absorption spectrophotometric method 《铜和铜合金的化学分析 铁含量的测定 分子吸收分光光度计法》.pdf
  • 相关搜索

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

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