【计算机类职业资格】计算机二级(C)上机考试11及答案解析.doc

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

1、计算机二级(C)上机考试 11及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 str 是一个由数字和字母字符组成的字符串,由变量 num传入字符串长度。请补充函数 fun(),该函数的功能是:把字符串 str中的数字字符转换成数字并存放到整型数组 bb中,函数返回数组 bb的长度。 例如:str=“Bcd123e456hui890”,结果为:123456890。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #define N 80 int bbN; int

2、 fun(char s,int bb,int num) int i,n=0; for(i=0;i_2.改错题 下列给定程序中,函数 fun()的功能是找出 100n(不大于 1000)之间百位数字加十位数字等于个位数字的所有整数,把这些整数放在 s所指的数组中,个数作为函数值返回。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #define N 100 int fun(int *s, int n) int i,j,k,a,b,c; j=0; for(i=100; i 1000);num= fun(

3、a,n); printf(“/n/nThe result :/n“); for(i=0; i_3.编程题 请编写函数 fun(),它的功能是求 Fibonacci数列中小于 t的最大的一个数,结果由函数返回。其中 Fibonacci数列 F(n)的定义为 F(0)0,F(1)1 F(n)=F(n-1)+F(n-2) 例如:t=1000 时 ,函数值为 987。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。 试题程序: #include #include #include int fun(int t) main()

4、int n; clrscr(); n=1000; printf(“n=%d, f=%d/n“,n, fun(n); (分数:-1.00)_计算机二级(C)上机考试 11答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 str 是一个由数字和字母字符组成的字符串,由变量 num传入字符串长度。请补充函数 fun(),该函数的功能是:把字符串 str中的数字字符转换成数字并存放到整型数组 bb中,函数返回数组 bb的长度。 例如:str=“Bcd123e456hui890”,结果为:123456890。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在

5、函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #define N 80 int bbN; int fun(char s,int bb,int num) int i,n=0; for(i=0;i_正确答案:(【1】si= 0 j=0; for(i=100; i 1000);num= fun(a,n); printf(“/n/nThe result :/n“); for(i=0; i_正确答案:((1)错误:k=n; 正确:k=i; (2)错误:sj=i; 正确:sj+=i; )解析:错误 1:k 就是当前要被判断的数,是随着 i值的变化而变化的。 错误 2

6、在循环中,j 是数组的下标要递增。 3.编程题 请编写函数 fun(),它的功能是求 Fibonacci数列中小于 t的最大的一个数,结果由函数返回。其中 Fibonacci数列 F(n)的定义为 F(0)0,F(1)1 F(n)=F(n-1)+F(n-2) 例如:t=1000 时 ,函数值为 987。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。 试题程序: #include #include #include int fun(int t) main() int n; clrscr(); n=1000; pri

7、ntf(“n=%d, f=%d/n“,n, fun(n); (分数:-1.00)_正确答案:(int fun(int t) int a=1,b=1,c=0,i; /*a 代表第 n-2项,b 代表第 n-1项,c 代表第 n项*/ /*如果求得的数 c比指定比较的数小,则计算下一个 Fibonacci数,对 a,b重新置数*/ do c=a+b; a=b; b=c; while (c解析:根据所给数列定义不难发现,该数列最终的结果是由两个数列之和组成,所以可以在循环内部始终把 c看成是前两项之和(即第 n项),而 a始终代表第 n-2项,b 始终代表第 n-1项(通过不断地重新赋值来实现)。应注意,退出循环时得到的数 c是大于指定比较的数的最小的数,而它的前一个数就是小于指定比较的数的最大的数。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3388-1990 Aerospace Series Fasteners Externally Threaded in Heat Resisting Nickel Base Alloy NI - P100HT (Inconel 718) Classification 1275 MPa 650 Degrees Celsius Manufa.pdf AECMA PREN 3388-1990 Aerospace Series Fasteners Externally Threaded in Heat Resisting Nickel Base Alloy NI - P100HT (Inconel 718) Classification 1275 MPa 650 Degrees Celsius Manufa.pdf
  • AECMA PREN 3389-1990 Aerospace Series Fasteners Externally Threaded in Heat Resisting Nickel Base Alloy NI-P101HT (Waspaloy) Classification 1210 MPa 730 Degrees Celsius Manufacturi.pdf AECMA PREN 3389-1990 Aerospace Series Fasteners Externally Threaded in Heat Resisting Nickel Base Alloy NI-P101HT (Waspaloy) Classification 1210 MPa 730 Degrees Celsius Manufacturi.pdf
  • AECMA PREN 3391-2009 Aerospace series Rivets solid universal head in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 通用接头实心铆钉 公制系列.版本P1》.pdf AECMA PREN 3391-2009 Aerospace series Rivets solid universal head in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 通用接头实心铆钉 公制系列.版本P1》.pdf
  • AECMA PREN 3392-2009 Aerospace series Rivets solid universal head in aluminium alloy 2117 anodized or chromated metric series Edition P 1《航空航天系列.铝合金2117 通用接头实心铆钉 阳极氧化或铬酸盐处理 公制系列.版本.pdf AECMA PREN 3392-2009 Aerospace series Rivets solid universal head in aluminium alloy 2117 anodized or chromated metric series Edition P 1《航空航天系列.铝合金2117 通用接头实心铆钉 阳极氧化或铬酸盐处理 公制系列.版本.pdf
  • AECMA PREN 3393-2009 Aerospace series Rivets solid 100 degrees normal countersunk head with dome in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 圆顶状100°标称埋头实心铆钉 公制.pdf AECMA PREN 3393-2009 Aerospace series Rivets solid 100 degrees normal countersunk head with dome in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 圆顶状100°标称埋头实心铆钉 公制.pdf
  • AECMA PREN 3394-2009 Aerospace series Rivets solid 100 degrees normal countersunk head in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 100°标称埋头实心铆钉 公制系列.版本P1》.pdf AECMA PREN 3394-2009 Aerospace series Rivets solid 100 degrees normal countersunk head in aluminium alloy 2117 metric series Edition P 1《航空航天系列.铝合金2117 100°标称埋头实心铆钉 公制系列.版本P1》.pdf
  • AECMA PREN 3395-2009 Aerospace series Rivets solid 100 degrees normal countersunk head with dome in aluminium alloy 2017A metric series Edition P 1《航空航天系列.铝合金2017A 圆顶状100°标称埋头实心铆钉 .pdf AECMA PREN 3395-2009 Aerospace series Rivets solid 100 degrees normal countersunk head with dome in aluminium alloy 2017A metric series Edition P 1《航空航天系列.铝合金2017A 圆顶状100°标称埋头实心铆钉 .pdf
  • AECMA PREN 3396-2009 Aerospace series Rivets solid 100 Degrees normal countersunk head with dome in aluminium alloy 5056A metric series Edition P 1《航空航天系列.公制系列铝合金5056A圆顶100°标称埋头实心铆.pdf AECMA PREN 3396-2009 Aerospace series Rivets solid 100 Degrees normal countersunk head with dome in aluminium alloy 5056A metric series Edition P 1《航空航天系列.公制系列铝合金5056A圆顶100°标称埋头实心铆.pdf
  • AECMA PREN 3397-2009 Aerospace series Rivets solid universal head in aluminium alloy 7050 metric series Edition P 1《航空航天系列.公制系列铝合金7050通用接头实心铆钉.版本P1》.pdf AECMA PREN 3397-2009 Aerospace series Rivets solid universal head in aluminium alloy 7050 metric series Edition P 1《航空航天系列.公制系列铝合金7050通用接头实心铆钉.版本P1》.pdf
  • 相关搜索

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

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