【计算机类职业资格】三级网络技术-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 决定。将整数转变成字符串后,判断字符串是否左右对称。求得字符串长度后设置两个变量,一个从字符串的头开始向后移动,一个从字符串的倒数第一个元素开始向前移动,直到移至数组的中间元素。若两者所决定的数组元素均相等,则字符串左右对称。

展开阅读全文
相关资源
猜你喜欢
  • DIN ISO 20727-2006 Textile machinery - Mixing bale openers for cotton spinning - Vocabulary and principles of construction (ISO 20727 2004) text in German English and French《纺织机械 棉.pdf DIN ISO 20727-2006 Textile machinery - Mixing bale openers for cotton spinning - Vocabulary and principles of construction (ISO 20727 2004) text in German English and French《纺织机械 棉.pdf
  • DIN ISO 20773-2017 Cigarettes - Determination of nicotine-free dry particulate matter and nicotine in sidestream smoke - Method using a routine analytical linear smoking machine eq卷.pdf DIN ISO 20773-2017 Cigarettes - Determination of nicotine-free dry particulate matter and nicotine in sidestream smoke - Method using a routine analytical linear smoking machine eq卷.pdf
  • DIN ISO 20774-2017 Cigarettes - Determination of carbon monoxide in sidestream smoke - Method using a routine analytical linear smoking machine equipped with a fishtail chimney (IS.pdf DIN ISO 20774-2017 Cigarettes - Determination of carbon monoxide in sidestream smoke - Method using a routine analytical linear smoking machine equipped with a fishtail chimney (IS.pdf
  • DIN ISO 20785-2-2016 Dosimetry for exposures to cosmic radiation in civilian aircraft - Part 2 Characterization of instrument response (ISO 20785-2 2011)《民用飞机曝露于宇宙辐射的放射量测定 第2部分 仪器响.pdf DIN ISO 20785-2-2016 Dosimetry for exposures to cosmic radiation in civilian aircraft - Part 2 Characterization of instrument response (ISO 20785-2 2011)《民用飞机曝露于宇宙辐射的放射量测定 第2部分 仪器响.pdf
  • DIN ISO 20816-1-2017 Mechanical vibration - Measurement and evaluation of machine vibration - Part 1 General guidelines (ISO 20816-1 2016)《机械振动 机械振动的测量和评估 第1部分 通用指南(ISO 20816-1-201.pdf DIN ISO 20816-1-2017 Mechanical vibration - Measurement and evaluation of machine vibration - Part 1 General guidelines (ISO 20816-1 2016)《机械振动 机械振动的测量和评估 第1部分 通用指南(ISO 20816-1-201.pdf
  • DIN ISO 20966-2008 Automatic milking installations - Requirements and testing (ISO 20966 2007) English version of DIN ISO 20966 2008-04《自动挤奶设备 要求和测试》.pdf DIN ISO 20966-2008 Automatic milking installations - Requirements and testing (ISO 20966 2007) English version of DIN ISO 20966 2008-04《自动挤奶设备 要求和测试》.pdf
  • DIN ISO 2108-2007 Information and documentation - International standard book numbering (ISBN) (ISO 2108 2005) English version of DIN ISO 2108 2007-01《信息和文件管理 国际标准图书编号(ISBN)(ISO 21.pdf DIN ISO 2108-2007 Information and documentation - International standard book numbering (ISBN) (ISO 2108 2005) English version of DIN ISO 2108 2007-01《信息和文件管理 国际标准图书编号(ISBN)(ISO 21.pdf
  • DIN ISO 21147-2005 Fine-cut tobacco and smoking articles made from it - Survey and analysis of consumer-made articles (ISO 21147 2003)《切细烟草及其烟制品 吸烟后所产生物质的检查和分析》.pdf DIN ISO 21147-2005 Fine-cut tobacco and smoking articles made from it - Survey and analysis of consumer-made articles (ISO 21147 2003)《切细烟草及其烟制品 吸烟后所产生物质的检查和分析》.pdf
  • DIN ISO 2115-2001 Plastics - Polymer dispersions - Determination of white point temperature and minimum film-forming temperature (ISO 2115 1996)《塑料 聚合物分散体 白点温度和最低膜成形温度测定》.pdf DIN ISO 2115-2001 Plastics - Polymer dispersions - Determination of white point temperature and minimum film-forming temperature (ISO 2115 1996)《塑料 聚合物分散体 白点温度和最低膜成形温度测定》.pdf
  • 相关搜索

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

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