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

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

1、二级 C 语言-51 及答案解析(总分:74.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:4.00)1.以下程序的输出结果是_。 #include stdio.h main() int a5=2,4,6,8,10,*p; p=a;p+; prinft(“%d“,*p); (分数:4.00)填空项 1:_二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中函数 fun 的功能是:用递归算法计算斐波拉契数列中第 n 项的值。从第 1 项起,斐波拉契数列为:1,1,2,3,58,13,21, 例如,若给 n 输入 7,则该项的斐波拉契数值为 13。 请改正程序中的错

2、误,使它能得出正确结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 试题程序: #includestdio.h long fun(int g) /*found*/ switch(g); case 0:return 0; /*found*/ case 1;case 2:return 1; return(fun(g-1)+fun(g-2); void main() long fib;int n; printf(“Input n:“); scanf(“%d“, int n, i=0; clrscr(); prlntf(“输入若干个字符串“); gets(ssi); pu

3、ts(ssi); while(!strcmp(ssi, “*“)=0) /*用*作为结束输入的标志*/ i+; gets(ssi);puts(ssi); n=i; ps=fun(ss,n, print(“/nmax=%s/n“,ps); (分数:40.00)_二级 C 语言-51 答案解析(总分:74.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:4.00)1.以下程序的输出结果是_。 #include stdio.h main() int a5=2,4,6,8,10,*p; p=a;p+; prinft(“%d“,*p); (分数:4.00)填空项 1:_ (正确答案:4)

4、解析:解析 在主函数中,语句 p=a;p+使用指针 p 指向数组 a1,所以输出结果为 4。二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中函数 fun 的功能是:用递归算法计算斐波拉契数列中第 n 项的值。从第 1 项起,斐波拉契数列为:1,1,2,3,58,13,21, 例如,若给 n 输入 7,则该项的斐波拉契数值为 13。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 试题程序: #includestdio.h long fun(int g) /*found*/ switch(g); case 0:r

5、eturn 0; /*found*/ case 1;case 2:return 1; return(fun(g-1)+fun(g-2); void main() long fib;int n; printf(“Input n:“); scanf(“%d“, int n, i=0; clrscr(); prlntf(“输入若干个字符串“); gets(ssi); puts(ssi); while(!strcmp(ssi, “*“)=0) /*用*作为结束输入的标志*/ i+; gets(ssi);puts(ssi); n=i; ps=fun(ss,n, print(“/nmax=%s/n“,ps); (分数:40.00)_正确答案:(fun(char (*a)81, int num, char *max) int i=0; max=a0; for (i=0; inum; i+) /*找出最长的一个字符串*/ if(strlen(max)strlen(ai) max=ai; return max; /*传回最长字符串地址*/ )解析:解析 做本题之前,我们先应该明白 ss 是一个指向一维数组的指针变量,max 是指向指针变量的指针变量。所以引用时要注意加上*。我们不可能只用 max,因为 ss0是一个数组地址而不是一个指针的地址。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 11546-2-2010 Acoustics - Determination of sound insulation performances of enclosures - Part 2 Measurements in situ (for acceptance and verification purposes) (ISO 11546.pdf DIN EN ISO 11546-2-2010 Acoustics - Determination of sound insulation performances of enclosures - Part 2 Measurements in situ (for acceptance and verification purposes) (ISO 11546.pdf
  • DIN EN ISO 11547 Berichtigung 1-2001 Corrigendum to DIN EN ISO 11547 1995 (German version EN ISO 11547 A1 2000)《DIN EN ISO 11547-1995的技术勘误》.pdf DIN EN ISO 11547 Berichtigung 1-2001 Corrigendum to DIN EN ISO 11547 1995 (German version EN ISO 11547 A1 2000)《DIN EN ISO 11547-1995的技术勘误》.pdf
  • DIN EN ISO 11547-1995 Small craft - Start-in-gear protection (ISO 11547 1994) German version EN ISO 11547 1995《小型船舶 起动啮合保护装置 (ISO 11547 1994) 德文版本 EN ISO 11547 1995》.pdf DIN EN ISO 11547-1995 Small craft - Start-in-gear protection (ISO 11547 1994) German version EN ISO 11547 1995《小型船舶 起动啮合保护装置 (ISO 11547 1994) 德文版本 EN ISO 11547 1995》.pdf
  • DIN EN ISO 11551-2004 Optics and optical instruments - Lasers and laser-related equipment - Test method for absorptance of optical laser components (ISO 11551 2003) German version .pdf DIN EN ISO 11551-2004 Optics and optical instruments - Lasers and laser-related equipment - Test method for absorptance of optical laser components (ISO 11551 2003) German version .pdf
  • DIN EN ISO 11553-1-2009 Safety of machinery - Laser processing machines - Part 1 General safety requirements (ISO 11553-1 2005) English version of DIN EN ISO 11553-1 2009-03《机械的安全性.pdf DIN EN ISO 11553-1-2009 Safety of machinery - Laser processing machines - Part 1 General safety requirements (ISO 11553-1 2005) English version of DIN EN ISO 11553-1 2009-03《机械的安全性.pdf
  • DIN EN ISO 11553-2-2009 Safety of machinery - Laser processing machines - Part 2 Safety requirements for hand-held laser processing devices (ISO 11553-2 2007) English version of DI.pdf DIN EN ISO 11553-2-2009 Safety of machinery - Laser processing machines - Part 2 Safety requirements for hand-held laser processing devices (ISO 11553-2 2007) English version of DI.pdf
  • DIN EN ISO 11553-3-2013 Safety of machinery - Laser processing machines - Part 3 Noise reduction and noise measurement methods for laser processing machines and hand-held processin.pdf DIN EN ISO 11553-3-2013 Safety of machinery - Laser processing machines - Part 3 Noise reduction and noise measurement methods for laser processing machines and hand-held processin.pdf
  • DIN EN ISO 1158-1998 Plastics - Vinyl chloride homopolymers and copolymers - Determination of chlorine content (ISO 1158 1998) German version EN ISO 1158 1998《塑料 氯乙烯均聚物和共聚物 氯含量的测定》.pdf DIN EN ISO 1158-1998 Plastics - Vinyl chloride homopolymers and copolymers - Determination of chlorine content (ISO 1158 1998) German version EN ISO 1158 1998《塑料 氯乙烯均聚物和共聚物 氯含量的测定》.pdf
  • DIN EN ISO 11591-2011 Small craft engine-driven - Field of vision from helm position (ISO 11591 2011) German version EN ISO 11591 2011《发动机驱动小艇 掌舵位置视野(ISO11591 2011) 德文版 EN ISO 1159.pdf DIN EN ISO 11591-2011 Small craft engine-driven - Field of vision from helm position (ISO 11591 2011) German version EN ISO 11591 2011《发动机驱动小艇 掌舵位置视野(ISO11591 2011) 德文版 EN ISO 1159.pdf
  • 相关搜索

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

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