【计算机类职业资格】全国计算机二级C语言上机试题73+2015年及答案解析.doc

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

1、全国计算机二级 C 语言上机试题 73+2015 年及答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中,函数 fun 的功能是计算下式 例如:若形参 e 的值为 1e-3,函数的返回值为 0.551690。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! 给定源程序: #include double fun(double e) int i, k; double s, t, x; s=0; k=1; i=2; /*found*/ x=_1_/4; /*foun

2、d*/ while(x _2_ e) s=s+k*x; k=k* (-1); t=2*i; /*found*/ x=_3_/(t*t); i+; return s; main() double e=1e-3; printf(“/nThe result is: %f/n“,fun(e); (分数:10.00)_2.给定程序 MODI1.C 中函数 fun 的功能是:求出以下分数序列的前 n 项之和。和值通过函数值返回到main 函数。 2 3 5 8 13 21 , , , , , , 1 2 3 5 8 13 例如,若 n = 5,则应输出:8.391667。 请改正程序中的错误,使它能计算出

3、正确的结果。 注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include /*found*/ fun ( int n ) int a, b, c, k; double s; s = 0.0; a = 2; b = 1; for ( k = 1; k 。 第三处:分子的值是 2i+1,所以应填:2*i+1。)解析:2.给定程序 MODI1.C 中函数 fun 的功能是:求出以下分数序列的前 n 项之和。和值通过函数值返回到main 函数。 2 3 5 8 13 21 , , , , , , 1 2 3 5 8 13 例如,若 n = 5,则应输出:8.3

4、91667。 请改正程序中的错误,使它能计算出正确的结果。 注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include /*found*/ fun ( int n ) int a, b, c, k; double s; s = 0.0; a = 2; b = 1; for ( k = 1; k = n; k+ ) /*found*/ s = s + (Double)a / b; c = a; a = a + b; b = c; return s; main( ) int n = 5; printf( “/nThe value of function i

5、s: %lf/n“, fun ( n ) ); (分数:10.00)_正确答案:(第一处:由于计算的实型值要通过函数返回,所以必须定义函数的返回类型,只要 int 或void 可以省略,其他都要定义类型。由于返回是实型值,所以应在数名前加上 double 或 float 等定义。 第二处:double 的第 1 个字母错写成大写 D。)解析:3.请编写一个函数 fun,它的功能是:求出一个 2M 整型二维数组中最大元素的值,并将此值返回调用函数。 注意: 部分源程序存在文件 PROG1.C 文件中。 请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include #define M 4 fun (int aM) main( ) int arr2M=5,8,3,45,76,-4,12,82 ; printf(“max =%d/n“, fun(arr) ; NONO( ) ; (分数:10.00)_正确答案:(fun (int aM) int i, j, max=a00; for(i=0; i解析:

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 17989-1-2016 Tractors and machinery for agriculture and forestry - Sustainability - Part 1 Principles (ISO 17989-1 2015) German version EN ISO 17989-1 2015《农林业用拖拉机和机械 可持.pdf DIN EN ISO 17989-1-2016 Tractors and machinery for agriculture and forestry - Sustainability - Part 1 Principles (ISO 17989-1 2015) German version EN ISO 17989-1 2015《农林业用拖拉机和机械 可持.pdf
  • DIN EN ISO 17993-2004 Water quality - Determination of 15 polycyclic aromatic hydrocarbons (PAH) in water by HPLC with fluorescence detection after liquid-liquid extraction (ISO 17.pdf DIN EN ISO 17993-2004 Water quality - Determination of 15 polycyclic aromatic hydrocarbons (PAH) in water by HPLC with fluorescence detection after liquid-liquid extraction (ISO 17.pdf
  • DIN EN ISO 17994-2014 Water quality - Requirements for the comparison of the relative recovery of microorganisms by two quantitative methods (ISO 17994 2014) German version EN ISO .pdf DIN EN ISO 17994-2014 Water quality - Requirements for the comparison of the relative recovery of microorganisms by two quantitative methods (ISO 17994 2014) German version EN ISO .pdf
  • DIN EN ISO 180-2013 Plastics - Determination of Izod impact strength (ISO 180 2000 + Amd 1 2006 + Amd 2 2013) German version EN ISO 180 2000 + A1 2006 + A2 2013《塑料 伊兆特(Izod)冲击强度的测定.pdf DIN EN ISO 180-2013 Plastics - Determination of Izod impact strength (ISO 180 2000 + Amd 1 2006 + Amd 2 2013) German version EN ISO 180 2000 + A1 2006 + A2 2013《塑料 伊兆特(Izod)冲击强度的测定.pdf
  • DIN EN ISO 1805-2007 Fishing nets - Determination of breaking force and knot breaking force of netting yarns (ISO 1805 2006) English version of DIN EN ISO 1805 2007-02《渔网 网线断裂强度和打结.pdf DIN EN ISO 1805-2007 Fishing nets - Determination of breaking force and knot breaking force of netting yarns (ISO 1805 2006) English version of DIN EN ISO 1805 2007-02《渔网 网线断裂强度和打结.pdf
  • DIN EN ISO 1806-2003 Fishing nets - Determination of mesh breaking force of netting (ISO 1806 2002) German version EN ISO 1806 2002《鱼网 拉网网眼断裂力测定》.pdf DIN EN ISO 1806-2003 Fishing nets - Determination of mesh breaking force of netting (ISO 1806 2002) German version EN ISO 1806 2002《鱼网 拉网网眼断裂力测定》.pdf
  • DIN EN ISO 18064-2015 Thermoplastic elastomers - Nomenclature and abbreviated terms (ISO18064 2014) German version EN ISO 18064 2014《热塑性弹性体 术语和简化术语(ISO18064-2014) 德文版本EN ISO 18064-.pdf DIN EN ISO 18064-2015 Thermoplastic elastomers - Nomenclature and abbreviated terms (ISO18064 2014) German version EN ISO 18064 2014《热塑性弹性体 术语和简化术语(ISO18064-2014) 德文版本EN ISO 18064-.pdf
  • DIN EN ISO 18081-2016 Non-destructive testing - Acoustic emission testing (AT) - Leak detection by means of acoustic emission (ISO 18081 2016) German version EN ISO 18081 2016《无损试验.pdf DIN EN ISO 18081-2016 Non-destructive testing - Acoustic emission testing (AT) - Leak detection by means of acoustic emission (ISO 18081 2016) German version EN ISO 18081 2016《无损试验.pdf
  • DIN EN ISO 18103-2015 Superfine woven wool fabric labelling - Requirements for Super S code definition (ISO 18103 2015) German version EN ISO 18103 2015《超细编织羊毛织物标签 超级S代码定义要求 (ISO 1.pdf DIN EN ISO 18103-2015 Superfine woven wool fabric labelling - Requirements for Super S code definition (ISO 18103 2015) German version EN ISO 18103 2015《超细编织羊毛织物标签 超级S代码定义要求 (ISO 1.pdf
  • 相关搜索

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

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