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

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

1、全国计算机二级 C语言上机试题 50+2015年及答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中,函数 fun的功能是:有 NN矩阵,以主对角线为对称线,对称元素相加并将结果存放在左下三角元素中,右上三角元素置为 0。例如,若 N=3,有下列矩阵: 1 2 3 4 5 6 7 8 9 计算结果为 1 0 0 6 5 0 10 14 9 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include #define N 4 /*found*/ v

2、oid fun(int (*t)_1_ ) int i, j; for(i=1; i for(j=0; j /*found*/ _2_ =tij+tji; /*found*/ _3_ =0; main() int tN=21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10, i, j; printf(“/nThe original array:/n“); for(i=0; i for(j=0; jprintf(“/n“); fun(t); printf(“/nThe result is:/n“); for(i=0; i for(j=0; jprintf

3、(“/n“); (分数:10.00)_2.给定程序 MODI1.C中函数 fun的功能是:计算函数 F(x,y,z)=(x+y)/(x-y)+(z+y)/(z-y)的值。其中 x和 y的值不等,z 和 y的值不等。 例如,当 x的值为 9、y 的值为 11、z 的值为 15时,函数值为 -3.50。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 给定源程序: #include #include #include /*found*/ #define FU(m,n) (m/n) float fun(float a,float b,f

4、loat c) float value; value=FU(a+b,a-b)+FU(c+b,c-b); /*found*/ Return(Value); main() float x,y,z,sum; printf(“Input x y z: “); scanf(“%f%f%f“, printf(“x=%f,y=%f,z=%f/n“,x,y,z); if (x=y|y=z)printf(“Data error!/n“);exit(0); sum=fun(x,y,z); printf(“The result is : %5.2f/n“,sum); (分数:10.00)_3.规定输入的字符串中只包

5、含字母和*号。请编写函数 fun,它的功能是:将字符串中的前导*号全部删除,中间和尾部的*号不删除。 例如,字符串中的内容为:*A*BC*DEF*G*,删除后,字符串中的内容应当是:A*BC*DEF*G*。在编写函数时,不得使用 C语言提供的字符串函数。 注意: 部分源程序在文件 PROG1.C中。请勿改动主函数 main和其它函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 给定源程序: #include void fun( char *a ) main() char s81; printf(“Enter a string:/n“);gets(s); fun( s ); p

6、rintf(“The string after deleted:/n“);puts(s); NONO(); (分数:10.00)_全国计算机二级 C语言上机试题 50+2015年答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中,函数 fun的功能是:有 NN矩阵,以主对角线为对称线,对称元素相加并将结果存放在左下三角元素中,右上三角元素置为 0。例如,若 N=3,有下列矩阵: 1 2 3 4 5 6 7 8 9 计算结果为 1 0 0 6 5 0 10 14 9 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK

7、1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include #define N 4 /*found*/ void fun(int (*t)_1_ ) int i, j; for(i=1; i for(j=0; j /*found*/ _2_ =tij+tji; /*found*/ _3_ =0; main() int tN=21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10, i, j; printf(“/nThe original array:/n“); for(i=0; i for(j=0; jprintf(“/n“); f

8、un(t); printf(“/nThe result is:/n“); for(i=0; i for(j=0; jprintf(“/n“); (分数:10.00)_正确答案:(第一处:形参 t的定义,整数数组其宽度为 N,所以应填:N。 第二处:对称元素相加,其结果仍存放在左下三角元素中,所以应填:tij。 第三处:右上三角元素置为 0,所以应填:tji。)解析:2.给定程序 MODI1.C中函数 fun的功能是:计算函数 F(x,y,z)=(x+y)/(x-y)+(z+y)/(z-y)的值。其中 x和 y的值不等,z 和 y的值不等。 例如,当 x的值为 9、y 的值为 11、z 的值为

9、15时,函数值为 -3.50。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 给定源程序: #include #include #include /*found*/ #define FU(m,n) (m/n) float fun(float a,float b,float c) float value; value=FU(a+b,a-b)+FU(c+b,c-b); /*found*/ Return(Value); main() float x,y,z,sum; printf(“Input x y z: “); scanf(“%f

10、%f%f“, printf(“x=%f,y=%f,z=%f/n“,x,y,z); if (x=y|y=z)printf(“Data error!/n“);exit(0); sum=fun(x,y,z); printf(“The result is : %5.2f/n“,sum); (分数:10.00)_正确答案:(第一处:define 定义错误,所以应改为:#define FU(m,n) (m)/(n)。 第二处:return 错写成 Return,变量 value错写成 Value。)解析:3.规定输入的字符串中只包含字母和*号。请编写函数 fun,它的功能是:将字符串中的前导*号全部删除,

11、中间和尾部的*号不删除。 例如,字符串中的内容为:*A*BC*DEF*G*,删除后,字符串中的内容应当是:A*BC*DEF*G*。在编写函数时,不得使用 C语言提供的字符串函数。 注意: 部分源程序在文件 PROG1.C中。请勿改动主函数 main和其它函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 给定源程序: #include void fun( char *a ) main() char s81; printf(“Enter a string:/n“);gets(s); fun( s ); printf(“The string after deleted:/n“);puts(s); NONO(); (分数:10.00)_正确答案:(void fun( char *a ) int j=0; char *p = a ; while(*p = *) p+ ; while(*p) aj+ = *p ; p+; aj=0 ; )解析:

展开阅读全文
相关资源
猜你喜欢
  • IEC PAS 62815-1-2013 Cold cathode fluorescent lamps - Part 1 Safety specifications (Edition 1.0)《冷阴极荧光灯.第1部分 安全性规范》.pdf IEC PAS 62815-1-2013 Cold cathode fluorescent lamps - Part 1 Safety specifications (Edition 1.0)《冷阴极荧光灯.第1部分 安全性规范》.pdf
  • IEC PAS 62815-2-2013 Cold cathode fluorescent lamps – Part 2 Performance specifications (Edition 1.0)《冷阴极荧光灯.第2部分 性能规范》.pdf IEC PAS 62815-2-2013 Cold cathode fluorescent lamps – Part 2 Performance specifications (Edition 1.0)《冷阴极荧光灯.第2部分 性能规范》.pdf
  • IEC PAS 62816-1-2013 External electrode fluorescent lamps – Part 1 Safety specifications (Edition 1.0)《外部电极荧光灯.第1部分 安全性规范》.pdf IEC PAS 62816-1-2013 External electrode fluorescent lamps – Part 1 Safety specifications (Edition 1.0)《外部电极荧光灯.第1部分 安全性规范》.pdf
  • IEC PAS 62816-2-2013 External electrode fluorescent lamps – Part 2 Performance specifications (Edition 1.0)《外部电极荧光灯.第2部分 性能规范》.pdf IEC PAS 62816-2-2013 External electrode fluorescent lamps – Part 2 Performance specifications (Edition 1.0)《外部电极荧光灯.第2部分 性能规范》.pdf
  • IEC PAS 63124-2017 Tumble dryers for commercial use - Methods for measuring the performance《商用滚筒式烘干机 性能测量方法》.pdf IEC PAS 63124-2017 Tumble dryers for commercial use - Methods for measuring the performance《商用滚筒式烘干机 性能测量方法》.pdf
  • IEC PAS 63125-2017 Clothes washing machines for commercial use - Methods for measuring the performance《商用洗衣机 性能测量方法》.pdf IEC PAS 63125-2017 Clothes washing machines for commercial use - Methods for measuring the performance《商用洗衣机 性能测量方法》.pdf
  • IEC TR 60071-4-2004 Insulation co-ordination - Part 4 Computational guide to insulation co-ordination and modelling of electrical networks《绝缘配合.第4部分 绝缘配合的计算指南和电子网络模拟》.pdf IEC TR 60071-4-2004 Insulation co-ordination - Part 4 Computational guide to insulation co-ordination and modelling of electrical networks《绝缘配合.第4部分 绝缘配合的计算指南和电子网络模拟》.pdf
  • IEC TR 60079-16-1990 Electrical apparatus for explosive gas atmospheres part 16 artificial ventilation for the protection of analyzer(s) houses《爆炸性气体环境用电气设备 第16部分 保护分析仪器房屋的人工通风》.pdf IEC TR 60079-16-1990 Electrical apparatus for explosive gas atmospheres part 16 artificial ventilation for the protection of analyzer(s) houses《爆炸性气体环境用电气设备 第16部分 保护分析仪器房屋的人工通风》.pdf
  • IEC TR 60083-2015 Plugs and socket-outlets for domestic and similar general use standardized in member countries of IEC《IEC成员国中标准化的家用和类似通用插头和插座》.pdf IEC TR 60083-2015 Plugs and socket-outlets for domestic and similar general use standardized in member countries of IEC《IEC成员国中标准化的家用和类似通用插头和插座》.pdf
  • 相关搜索

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

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