【计算机类职业资格】二级C语言机试8及答案解析.doc

上传人:priceawful190 文档编号:1325891 上传时间:2019-10-17 格式:DOC 页数:2 大小:34KB
下载 相关 举报
【计算机类职业资格】二级C语言机试8及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】二级C语言机试8及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、二级 C 语言机试 8 及答案解析(总分:100.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:30.00)1.请补充函数 fun(),该函数的功能是:计算 NN 维矩阵元素的方差,结果由函数返回。维数 N 在主函数中输入。例如: (分数:30.00)填空项 1:_二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中,函数 fun()的功能是将字符串 s 中位于偶数位置的字符或 ASCII 码为奇数的字符放入字符串 t 中(规定第一个字符放在第 0 位中)。 例如:字符串中的数据为 ADFESHDI,则输出应当是 AFESDI。 请改正程序中的错误,使它能得到正

2、确结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include conio.h #include stdio.h #include string.h #define N 80 /*found*/ void fun(char s,char t) int i,j=0; for(i=0;istrlen(s);i+) /*found*+*/ if(i%2=0 | si%2!=0) tj+=si; tj=/0; main() char sN,tN; clrscr(); printf(“/nPlease enter string s:“); gets(s);

3、 fun(s,t); printf(“/nThe result is:%s/n“,t); (分数:30.00)填空项 1:_三、B编程题/B(总题数:1,分数:40.00)3.请编写一个函数 fun(),它的功能是计算并输出给定整数 n 的所有因子(不包括 1 与自身)的平方和(规定 n 的值不大于 100)。 例如:主函数从键盘给输入 n 的值为 56,则输出为 sum=1113。 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。 试题程序: #include stdio.h long fun(int n) main() int n; long sum; printf(“Input n:“); scanf(“%d“,i+) /*从 2n-1 中找 n 的所有因子*/ if(n%i=0) s+=i*i; /*将所有因子求平方加*/ return s; /*将平方和返回*/ 解析本题的解题思路是用 n 逐个去除以 2 到 n-1 之间的所有数,如果 n 能被除尽,则把所得到的一个因子的平方累加到 s中去。

展开阅读全文
相关资源
猜你喜欢
  • ISO 20683-1-2016 Aircraft ground equipment - Nose gear towbarless towing vehicle (TLTV) - Design testing and maintenance requirements - Part 1 Main line aircraf.pdf ISO 20683-1-2016 Aircraft ground equipment - Nose gear towbarless towing vehicle (TLTV) - Design testing and maintenance requirements - Part 1 Main line aircraf.pdf
  • ISO 20683-2-2016 Aircraft ground equipment - Design testing and maintenance requirements for nose gear towbarless towing vehicle (TLTV) - Part 2 Regional aircra.pdf ISO 20683-2-2016 Aircraft ground equipment - Design testing and maintenance requirements for nose gear towbarless towing vehicle (TLTV) - Part 2 Regional aircra.pdf
  • ISO 20685-2-2015 Ergonomics - 3-D scanning methodologies for internationally compatible anthropometric databases - Part 2 Evaluation protocol of surface shape a.pdf ISO 20685-2-2015 Ergonomics - 3-D scanning methodologies for internationally compatible anthropometric databases - Part 2 Evaluation protocol of surface shape a.pdf
  • ISO 2069-1976 Aluminium oxide primarily used for the production of aluminium Determination of calcium content Flame atomic absorption method《主要用于铝生产的氧化铝 钙含量的测定 .pdf ISO 2069-1976 Aluminium oxide primarily used for the production of aluminium Determination of calcium content Flame atomic absorption method《主要用于铝生产的氧化铝 钙含量的测定 .pdf
  • ISO 2070-1997 Aluminium oxide primarily used for the production of aluminium - Determination of calcium content《主要用于铝生产的氧化铝 钙含量的测定》.pdf ISO 2070-1997 Aluminium oxide primarily used for the production of aluminium - Determination of calcium content《主要用于铝生产的氧化铝 钙含量的测定》.pdf
  • ISO 20700-2017 Guidelines for management consultancy services《管理顾问服务指南》.pdf ISO 20700-2017 Guidelines for management consultancy services《管理顾问服务指南》.pdf
  • ISO 20703-2006 Gas cylinders - Refillable welded aluminium-alloy cylinders - Design construction and testing《气瓶 可再充装的焊接铝合金气瓶 设计、结构和试验》.pdf ISO 20703-2006 Gas cylinders - Refillable welded aluminium-alloy cylinders - Design construction and testing《气瓶 可再充装的焊接铝合金气瓶 设计、结构和试验》.pdf
  • ISO 2071-1976 Aluminium oxide primarily used for the production of aluminium Determination of zinc content Flame atomic absorption method《主要用于铝生产的氧化铝 锌含量的测定 火焰原.pdf ISO 2071-1976 Aluminium oxide primarily used for the production of aluminium Determination of zinc content Flame atomic absorption method《主要用于铝生产的氧化铝 锌含量的测定 火焰原.pdf
  • ISO 20712-1-2008 Water safety signs and beach safety flags - Part 1 Specifications for water safety signs used in workplaces and public areas《水域安全标志和沙滩安全标志 第1部分.pdf ISO 20712-1-2008 Water safety signs and beach safety flags - Part 1 Specifications for water safety signs used in workplaces and public areas《水域安全标志和沙滩安全标志 第1部分.pdf
  • 相关搜索

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

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