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

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

1、二级 C语言机试-53 及答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:30.00)1.请补充函数 fun,其功能是:计算并输出给定 10个数的方差:(分数:30.00)填空项 1:_二、改错题(总题数:1,分数:30.00)2.下列给定程序中,函数 fun()的功能是:先从键盘上输入一个 3行 3列的矩阵的各个元素的值,然后输出主对角线元素之和。请改正函数 fun()中的错误,使它能得出正确的结果。注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include stdio.hint fun()int a3 3,sum;int

2、 i,j;/*found*/sum=1;for (i=0;i3;i+)for (j=0;j3;j+)/*found*/scanf(“%d“,aij);for(i=0;i3;i+)sum=sum+aii;printf(“Sum=%d/n“,sum);main()fun();(分数:30.00)填空项 1:_三、编程题(总题数:1,分数:40.00)3.printf“Input 2th string: “);(分数:40.00)_二级 C语言机试-53 答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:30.00)1.请补充函数 fun,其功能是:计算并输出给定 1

3、0个数的方差:(分数:30.00)填空项 1:_ (正确答案:1 sum+=xi 2 abs+=(xi-avg)*(xi-avg) 3 sqrt(abs/10))解析:解析 填空 1:根据求方差的公式可知,首先要求出 10个数的平均值,此处是利用 for循环对 10个数求累加和。填空 2:使用 for循环求出每个数与平均值之差的平方和。填空 3:通过开方,求出 10个数的方差,此处需要注意对库函数 sqrt()的调用。二、改错题(总题数:1,分数:30.00)2.下列给定程序中,函数 fun()的功能是:先从键盘上输入一个 3行 3列的矩阵的各个元素的值,然后输出主对角线元素之和。请改正函数

4、fun()中的错误,使它能得出正确的结果。注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include stdio.hint fun()int a3 3,sum;int i,j;/*found*/sum=1;for (i=0;i3;i+)for (j=0;j3;j+)/*found*/scanf(“%d“,aij);for(i=0;i3;i+)sum=sum+aii;printf(“Sum=%d/n“,sum);main()fun();(分数:30.00)填空项 1:_ (正确答案:错误:sun=1; 正确:sum=0;(2) 错误:scanf(“%d“,ai

5、j); 正确:scanf(“%d“,)解析:解析 该题依然考查对循环语句的掌握和对数组概念的理解,根据题干主线,我们可以看清这样的一个解题思路:先从键盘输入一个 33矩阵,然后再循环累加执行循环语句中的 sum=sum+aii,所以 sum=0。三、编程题(总题数:1,分数:40.00)3.printf“Input 2th string: “);(分数:40.00)_正确答案:(char *fun(char *s, char *t)int i,i;for(i=0;si!= /0;i+); /*求字符串的长度*/for(j=0;ti!= /0;j+);if(i=j) /*比较两个字符串的长度*/return s; /*函数返回较长的字符串,若两个字符串长度相等,则返回第 1个字符串*/elsereturn t;)解析:解析 本题中,第 1个 for循环的作用是求出 s的字符个数 i,第 2个 for循环的作用是求出 t的字符个数 j,因为任何循环都要控制一条语句,所以在每一个 for循环条件后面必须要有一个分号。本题也可用如下技巧:char *fun(char *s,char *t)if(strlen(s)=strlen(t) return s;else return t;

展开阅读全文
相关资源
猜你喜欢
  • CEN TR 15641-2007 Food analysis - Determination of pesticide residues by LCMS MS - Tandem mass spectrometric parameters《食品分析 用LC-MS MS测定农药残留物 串联质谱测定参数》.pdf CEN TR 15641-2007 Food analysis - Determination of pesticide residues by LCMS MS - Tandem mass spectrometric parameters《食品分析 用LC-MS MS测定农药残留物 串联质谱测定参数》.pdf
  • CEN TR 15642-2011 Unified tests procedures for the tests of EN 3-7 2004+A1 2007《统一测试程序测试的EN 3-7 2004 + A1 2007》.pdf CEN TR 15642-2011 Unified tests procedures for the tests of EN 3-7 2004+A1 2007《统一测试程序测试的EN 3-7 2004 + A1 2007》.pdf
  • CEN TR 15645-1-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the odour test - Part 1 Odour《与食品接触的纸和纸板 气味试验的校准 第1部分 气味》.pdf CEN TR 15645-1-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the odour test - Part 1 Odour《与食品接触的纸和纸板 气味试验的校准 第1部分 气味》.pdf
  • CEN TR 15645-2-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the off flavour test - Part 2 Fatty food (Incorporating corrigendum July 2008)《与食.pdf CEN TR 15645-2-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the off flavour test - Part 2 Fatty food (Incorporating corrigendum July 2008)《与食.pdf
  • CEN TR 15645-3-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the off-flavour test - Part 3 Dry food (Incorporating corrigendum July 2008)《与食品接.pdf CEN TR 15645-3-2008 Paper and board intended to come into contact with foodstuffs - Calibration of the off-flavour test - Part 3 Dry food (Incorporating corrigendum July 2008)《与食品接.pdf
  • CEN TR 15678-2008 Concrete - Release of regulated dangerous substances into soil groundwater and surface water - Test method for new or unapproved constituents of concrete and for .pdf CEN TR 15678-2008 Concrete - Release of regulated dangerous substances into soil groundwater and surface water - Test method for new or unapproved constituents of concrete and for .pdf
  • CEN TR 15697-2008 Cement - Performance testing for sulfate resistance - State of the art report《水泥 耐硫酸盐的性能测试 技术报告的情况》.pdf CEN TR 15697-2008 Cement - Performance testing for sulfate resistance - State of the art report《水泥 耐硫酸盐的性能测试 技术报告的情况》.pdf
  • CEN TR 15709-2008 Hardware for furniture - Terms for slide fittings for sliding doors and roll fronts《家具五金件 滑门和卷门滑动配件的术语》.pdf CEN TR 15709-2008 Hardware for furniture - Terms for slide fittings for sliding doors and roll fronts《家具五金件 滑门和卷门滑动配件的术语》.pdf
  • CEN TR 15716-2008 Solid recovered fuels - Determination of combustion behaviour《固体再生燃料 燃烧特性的测定》.pdf CEN TR 15716-2008 Solid recovered fuels - Determination of combustion behaviour《固体再生燃料 燃烧特性的测定》.pdf
  • 相关搜索

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

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