【计算机类职业资格】全国计算机等级考试二级C语言操作题14+2016年及答案解析.doc

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

1、全国计算机等级考试二级 C 语言操作题 14+2016 年及答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中, 函数 fun 的功能是用函数指针指向要调用的函数,并进行调用。规定在_2_处使 f 指向函数 f1,在_3_处使 f 指向函数 f2。当调用正确时,程序输出: x1=5.000000, x2=3.000000, x1*x1+x1*x2=40.000000 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include double

2、f1(double x) return x*x; double f2(double x, double y) return x*y; double fun(double a, double b) /*found*/ _1_ (*f)(); double r1, r2; /*found*/ f = _2_ ; /* point fountion f1 */ r1 = f(a); /*found*/ f = _3_ ; /* point fountion f2 */ r2 = (*f)(a, b); return r1 + r2; main() double x1=5, x2=3, r; r =

3、fun(x1, x2); printf(“/nx1=%f, x2=%f, x1*x1+x1*x2=%f/n“,x1, x2, r); (分数:10.00)_2.给定程序 MODI1.C 是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数 fun 的功能是将单向链表结点 (不包括头结点)数据域为偶数的值累加起来, 并且作为函数值返回。 请改正函数 fun 中指定部位的错误, 使它能得出正确的结果。 注意: 不要改动 main 函数, 不得增行或删行, 也不得更改程序的结构! 给定源程序: (分数:10.00)_3.请编写函数 fun, 函数的功能是: 判断字符串是否为回文?若是, 函数

4、返回 1,主函数中输出: YES, 否则返回 0, 主函数中输出 NO。回文是指顺读和倒读都一样的字符串。 例如, 字符串 LEVEL 是回文, 而字符串 123312 就不是回文。 注意:部分源程序在文件 PROG1.C 中。请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include #define N 80 int fun(char *str) main() char sN ; printf(“Enter a string: “) ; gets(s) ; printf(“/n/n“) ; puts(s) ; if(f

5、un(s) printf(“ YES/n“) ; else printf(“ NO/n“) ; NONO() ; (分数:10.00)_全国计算机等级考试二级 C 语言操作题 14+2016 年答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中, 函数 fun 的功能是用函数指针指向要调用的函数,并进行调用。规定在_2_处使 f 指向函数 f1,在_3_处使 f 指向函数 f2。当调用正确时,程序输出: x1=5.000000, x2=3.000000, x1*x1+x1*x2=40.000000 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源

6、程序存放在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include double f1(double x) return x*x; double f2(double x, double y) return x*y; double fun(double a, double b) /*found*/ _1_ (*f)(); double r1, r2; /*found*/ f = _2_ ; /* point fountion f1 */ r1 = f(a); /*found*/ f = _3_ ; /* point fountion f2 */

7、 r2 = (*f)(a, b); return r1 + r2; main() double x1=5, x2=3, r; r = fun(x1, x2); printf(“/nx1=%f, x2=%f, x1*x1+x1*x2=%f/n“,x1, x2, r); (分数:10.00)_正确答案:()解析:解题思路: 本题主要是考察用函数指针指向要调用的函数。程序中共有三处要填上适当的内容,使程序能运行出正确的结果。 第一处:定义函数指针的类型,所以应填:double。 第二处:使 f 指向函数 f1,所以应填:f1。 第三处:使 f 指向函数 f2,所以应填:f2。2.给定程序 MODI1

8、C 是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数 fun 的功能是将单向链表结点 (不包括头结点)数据域为偶数的值累加起来, 并且作为函数值返回。 请改正函数 fun 中指定部位的错误, 使它能得出正确的结果。 注意: 不要改动 main 函数, 不得增行或删行, 也不得更改程序的结构! 给定源程序: (分数:10.00)_正确答案:()解析:解题思路: 本题是考察如何使用单向链表把数据域的值按条件进行累加。 第一处:试题要求不计算头结点,所以应改为:p=h-next; 第二处:指向 p 的下一个结点来实现循环,所以应改为:p=p-next; 3.请编写函数 fun, 函数的

9、功能是: 判断字符串是否为回文?若是, 函数返回 1,主函数中输出: YES, 否则返回 0, 主函数中输出 NO。回文是指顺读和倒读都一样的字符串。 例如, 字符串 LEVEL 是回文, 而字符串 123312 就不是回文。 注意:部分源程序在文件 PROG1.C 中。请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include #define N 80 int fun(char *str) main() char sN ; printf(“Enter a string: “) ; gets(s) ; printf(“/n/n“) ; puts(s) ; if(fun(s) printf(“ YES/n“) ; else printf(“ NO/n“) ; NONO() ; (分数:10.00)_正确答案:(int fun(char *str) int i, j = strlen(str) ; for(i = 0 ; i j / 2 ; i+) if(stri != strj - i - 1) return 0 ; return 1 ; )解析:解题思路: 本题是考察如何判断一个字符串是回文字符串,回文是指顺读和倒读都一样的字符串。可以利用 for 循环语句来判断,如果前后不一致,则不是回文字符串。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 10816-8-2014 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Reciprocating compressor systems《机械振动 通过非旋转零件测量对机械振动的评估 往复式压缩机系统》.pdf BS ISO 10816-8-2014 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Reciprocating compressor systems《机械振动 通过非旋转零件测量对机械振动的评估 往复式压缩机系统》.pdf
  • BS ISO 10817-1-1999 Rotating shaft vibration measuring systems - Relative and absolute sensing of radial vibration《旋转轴振动测量系统 径向振动的相对和绝对信号检测》.pdf BS ISO 10817-1-1999 Rotating shaft vibration measuring systems - Relative and absolute sensing of radial vibration《旋转轴振动测量系统 径向振动的相对和绝对信号检测》.pdf
  • BS ISO 10830-2011 Space systems Non-destructive testing Automatic ultrasonic inspection method of graphite ingot for solid rocket motors《空间系统 无损检验 固体火箭发动机用石墨锭的自动超声波检查方法》.pdf BS ISO 10830-2011 Space systems Non-destructive testing Automatic ultrasonic inspection method of graphite ingot for solid rocket motors《空间系统 无损检验 固体火箭发动机用石墨锭的自动超声波检查方法》.pdf
  • BS ISO 10833-2017 Textile floor coverings Determination of resistance to damage at cut edges using the modified Vettermann drum test《纺织地板覆盖物 采用改良的维特曼鼓试验测定抗切边损坏》.pdf BS ISO 10833-2017 Textile floor coverings Determination of resistance to damage at cut edges using the modified Vettermann drum test《纺织地板覆盖物 采用改良的维特曼鼓试验测定抗切边损坏》.pdf
  • BS ISO 10834-1993 Textile floor coverings - Non-destructive measurement of pile thickness above the backing - WRONZ gauge method《纺织品铺地盖片 底布上绒头密度的无损测量 WRONZ量规法》.pdf BS ISO 10834-1993 Textile floor coverings - Non-destructive measurement of pile thickness above the backing - WRONZ gauge method《纺织品铺地盖片 底布上绒头密度的无损测量 WRONZ量规法》.pdf
  • BS ISO 10835-2007 Direct reduced iron and hot briquetted iron - Sampling and sample preparation《直接还原铁和热压铁 取样和制样》.pdf BS ISO 10835-2007 Direct reduced iron and hot briquetted iron - Sampling and sample preparation《直接还原铁和热压铁 取样和制样》.pdf
  • BS ISO 10842-2017 Aircraft Ground service connections Locations and types《飞行器 地面辅助联接 位置和类型》.pdf BS ISO 10842-2017 Aircraft Ground service connections Locations and types《飞行器 地面辅助联接 位置和类型》.pdf
  • BS ISO 10844-2014 Acoustics Specification of test tracks for measuring noise emitted by road vehicles and their tyres《声学 测量道路车辆及其轮胎发射的噪声用的试验车道的规范》.pdf BS ISO 10844-2014 Acoustics Specification of test tracks for measuring noise emitted by road vehicles and their tyres《声学 测量道路车辆及其轮胎发射的噪声用的试验车道的规范》.pdf
  • BS ISO 10845-1-2011 Construction procurement Processes methods and procedures《工程采购 流程 方法和程序》.pdf BS ISO 10845-1-2011 Construction procurement Processes methods and procedures《工程采购 流程 方法和程序》.pdf
  • 相关搜索

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

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