【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习26及答案解析.doc

上传人:twoload295 文档编号:1318138 上传时间:2019-10-17 格式:DOC 页数:4 大小:37KB
下载 相关 举报
【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习26及答案解析.doc_第1页
第1页 / 共4页
【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习26及答案解析.doc_第2页
第2页 / 共4页
【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习26及答案解析.doc_第3页
第3页 / 共4页
【计算机类职业资格】2018年计算机等级考试二级C语言程序题练习26及答案解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、2018 年计算机等级考试二级 C 语言程序题练习 26 及答案解析(总分:100.00,做题时间:60 分钟)一、程序填空题(总题数:1,分数:30.00)给定程序中,函数 fun 的功能是计算出形参 s 所指字符串中包含的单词个数,并作为函数值返回。 为便于统计,规定各单词之间用空格隔开,字符串 中只有字母与空格。例如,形参 s 所指的字符串为“This is a C language program”函数的返回值为 6。请在程序的下画线处填入正确的内容并把下画 线删除,使程序得出正确的结果。注意:源程序保存在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构!给定

2、源程序如下。(分数:30)(1)(分数:10)填空项 1:_(2)(分数:10)填空项 1:_(3)(分数:10)填空项 1:_二、程序改错题(总题数:1,分数:30.00)给定程序 MODI1.C 中函数 fun 的功能是从 n (形参)个学生的成绩中统计出低于平均分的学生人数, 此人数由函数值返回,平均分存放在形参 aver 所指 的存储单元中。例如,若输入 8 名学生的成绩:80.5、60、72、 90.5、98、51.5、88、64,则低于平均分的学生人数 为 4 (平均分为 75.5625 )。请改正程序中的错误,使它能统计出正确的 结果。注意:不要改动 main 函数,不得增行或删

3、扞, 也不得更改程序的结构!给定源程序如下。(分数:30.00)_三、程序设计题(总题数:1,分数:40.00)请编写函数 fun,其功能是求出数组的最大 元素在数组中的下标并存放在 k 所指的存储单 元中。例如,输入如下整数:876、675、896、101、 301、 401、 980、 431、 451、 777。则输出结果为 6980。注意:部分源程序保存在文件 PROG1.C 中。请勿改动主函数 main 和其他函数中的任何内 容,仅在函数 fun 的花括号中填入编写的若干语句。给定源程序如下。(分数:40.00)_2018 年计算机等级考试二级 C 语言程序题练习 26 答案解析(总

4、分:100.00,做题时间:60 分钟)一、程序填空题(总题数:1,分数:30.00)给定程序中,函数 fun 的功能是计算出形参 s 所指字符串中包含的单词个数,并作为函数值返回。 为便于统计,规定各单词之间用空格隔开,字符串 中只有字母与空格。例如,形参 s 所指的字符串为“This is a C language program”函数的返回值为 6。请在程序的下画线处填入正确的内容并把下画 线删除,使程序得出正确的结果。注意:源程序保存在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构!给定源程序如下。(分数:30)(1)(分数:10)填空项 1:_ (正确答案

5、n+)解析:单词个数用变量 n 来统计,当前字母 不是空格且 flag 状态标志为 0 时,可以判断出现一 个新的单词,则单词数就加 1,将状态标志 flag 置 为 1,所以应填 n+。(2)(分数:10)填空项 1:_ (正确答案:0)解析:当前字符是空格时,flag 状态标志置 0,所以应填 0。(3)(分数:10)填空项 1:_ (正确答案:s+)解析:判断完一个字符之后,要继续判断字 符串的下一个位置,所以应填 s+。二、程序改错题(总题数:1,分数:30.00)给定程序 MODI1.C 中函数 fun 的功能是从 n (形参)个学生的成绩中统计出低于平均分的学生人数, 此人数由函

6、数值返回,平均分存放在形参 aver 所指 的存储单元中。例如,若输入 8 名学生的成绩:80.5、60、72、 90.5、98、51.5、88、64,则低于平均分的学生人数 为 4 (平均分为 75.5625 )。请改正程序中的错误,使它能统计出正确的 结果。注意:不要改动 main 函数,不得增行或删扞, 也不得更改程序的结构!给定源程序如下。(分数:30.00)_正确答案:((1 ) t+=sk;(2 ) *aver=ave;)解析:根据题目要求,可利用循环语句累计 n 个学生 的总分,求得平均成绩后,再利用循环语句和条件 选择语句进行后面的操作。若小于平均值,则将该 值存放于 aver

7、 存储单元中。t=sk是循环叠加错误, *aver=Ave 为拼写错误。三、程序设计题(总题数:1,分数:40.00)请编写函数 fun,其功能是求出数组的最大 元素在数组中的下标并存放在 k 所指的存储单 元中。例如,输入如下整数:876、675、896、101、 301、 401、 980、 431、 451、 777。则输出结果为 6980。注意:部分源程序保存在文件 PROG1.C 中。请勿改动主函数 main 和其他函数中的任何内 容,仅在函数 fun 的花括号中填入编写的若干语句。给定源程序如下。(分数:40.00)_正确答案:()解析:本题中直接使用指针变量 k,使用时要注意对 k 进行指针运算。程序一开始让 k 指向数组中的第一 个元素,即*k=0。

展开阅读全文
相关资源
猜你喜欢
  • GOST 17128-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 400 to 500 mm width from 300 to 500 mm height from 100 to 250 mm Constru.pdf GOST 17128-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 400 to 500 mm width from 300 to 500 mm height from 100 to 250 mm Constru.pdf
  • GOST 17129-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 600 to 900 mm width from 500 to 700 mm height from 125 to 400 mm Constru.pdf GOST 17129-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 600 to 900 mm width from 500 to 700 mm height from 125 to 400 mm Constru.pdf
  • GOST 17130-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 900 to 1200 mm width 700 800 mm height from 150 to 400 mm Construction a.pdf GOST 17130-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 900 to 1200 mm width 700 800 mm height from 150 to 400 mm Construction a.pdf
  • GOST 17131-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 1000 to 1200 mm width 700 800 mm height 450 500 mm Construction and dime.pdf GOST 17131-1971 Rectangular weld moulding boxes of cast steel elements having inside dimensions length from 1000 to 1200 mm width 700 800 mm height 450 500 mm Construction and dime.pdf
  • GOST 17132-1971 Weld moulding boxes of cast steel elements Technical conditions《焊接铸钢型箱 技术条件》.pdf GOST 17132-1971 Weld moulding boxes of cast steel elements Technical conditions《焊接铸钢型箱 技术条件》.pdf
  • GOST 17133-1983 Rubber sheets for articles contacting with food stuff Specifications《接触食品类用品用橡胶板 规范》.pdf GOST 17133-1983 Rubber sheets for articles contacting with food stuff Specifications《接触食品类用品用橡胶板 规范》.pdf
  • GOST 17134-1980 Relay type radioisotope instruments General specifications《继电器式放射性同位素仪表 通用规范》.pdf GOST 17134-1980 Relay type radioisotope instruments General specifications《继电器式放射性同位素仪表 通用规范》.pdf
  • GOST 17137-1987 Monitoring control and protection systems of nuclear reactors Terms and definitions《核反应堆辐射监督、控制和防护系统 术语和定义》.pdf GOST 17137-1987 Monitoring control and protection systems of nuclear reactors Terms and definitions《核反应堆辐射监督、控制和防护系统 术语和定义》.pdf
  • GOST 17138-1981 Equipment for monitoring fuel element ruptures in nuclear reactors of nuclear power stations General technical requirements and test methods《原子能电站核反应堆释热元件外壳的密封性检测器 .pdf GOST 17138-1981 Equipment for monitoring fuel element ruptures in nuclear reactors of nuclear power stations General technical requirements and test methods《原子能电站核反应堆释热元件外壳的密封性检测器 .pdf
  • 相关搜索

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

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