[计算机类试卷]国家二级(C语言)机试模拟试卷298及答案与解析.doc

上传人:周芸 文档编号:503050 上传时间:2018-11-29 格式:DOC 页数:4 大小:34.50KB
下载 相关 举报
[计算机类试卷]国家二级(C语言)机试模拟试卷298及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家二级(C语言)机试模拟试卷298及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家二级(C语言)机试模拟试卷298及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家二级(C语言)机试模拟试卷298及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级( C语言)机试模拟试卷 298及答案与解析 一、程序填空题( 30分) 1 给定程序中,函数 fun的功能是:计算下式前 n项的和作为函数值返回。例如,当形参 n的值为 10时,函数返回: -0 204491。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意;源程序存放在考生文件夹下的 BLANKl C中。 不得增行或删行,也不得更改程序的结构 !#include double fun(int n) int i, k; double s, t; s=0; *found* k=【 1】; for(i=1; i0): “); scarlf(“ d“,&n);

2、 ) printf(“ nThe result is: f n“, fun(n); 二、程序修改题( 30分) 2 给定程序 MODIl C中函数 fun的功能是:从低位开始取出长整型变量 s中偶数位上的数,依次构成一个新数放在 t中。高位仍在高位,低位仍在低位。 例如,当 s中的数为: 7654321时, t中的数为: 642。 请改正程序中的错误,使它能得出正确的结果。 注意:不要 改动 main函数,不得增行或删行,也不得更改程序的结构 ! #include *found* void fun(10ng s, long t) long sl=10; s =10; *t=s 10; *fou

3、nd* while(s0) 【试题解析】 (1)第一个标识下的形参 t被定义为一个 long型变量,而对应的主函数中的实参却是一个地址值。因此, t在函数定义中应该被定义为一个指针变量,即 “void fun(10ng s long t)“改为 “void fun(long s,long*t)“。 (2)第二个标识下的 while循环控制表达式 “s0)“。 三、程序设计题( 40分) 3 【正确答案】 int i, j, n=0; double sum=0; for(i=0; iN; i+) sum+=w0i+wN一 1i; n+=2; for(i=1; iN-1; i+) sum+=wi0+wiN 1; n+=2; return sum n; 【试题解析】 进入 fun函数,根据前面的 分析,采用循环分别对符合周边元素条件的元素进行统计求平均值。

展开阅读全文
相关资源
猜你喜欢
  • BS PD CEN TR 15371-2-2017 Safety of toys Interpretations Replies to requests for interpretation of the chemical standards in the EN 71-series《玩具的安全性 解释 对EN 71系列中化学标准解释要求的答.pdf BS PD CEN TR 15371-2-2017 Safety of toys Interpretations Replies to requests for interpretation of the chemical standards in the EN 71-series《玩具的安全性 解释 对EN 71系列中化学标准解释要求的答.pdf
  • BS PD CEN TR 15378-2-2017 Energy performance of buildings Heating systems and DHW in buildings Explanation and justification of EN 15378-1 Module M3-11 and M8-11《建筑物能源性能 建.pdf BS PD CEN TR 15378-2-2017 Energy performance of buildings Heating systems and DHW in buildings Explanation and justification of EN 15378-1 Module M3-11 and M8-11《建筑物能源性能 建.pdf
  • BS PD CEN TR 15378-4-2017 Energy performance of buildings Heating systems and DHW in buildings Explanation and justification of EN 15378-3 Module M3-10 M8-10《建筑物能源性能 建筑物内供.pdf BS PD CEN TR 15378-4-2017 Energy performance of buildings Heating systems and DHW in buildings Explanation and justification of EN 15378-3 Module M3-10 M8-10《建筑物能源性能 建筑物内供.pdf
  • BS PD CEN TR 15404-2010 Solid recovered fuels — nMethods for the determination nof ash melting behaviour nby using characteristic ntemperatures《固体回收燃料–使用特征温度测定灰熔融行为的方法》.pdf BS PD CEN TR 15404-2010 Solid recovered fuels — nMethods for the determination nof ash melting behaviour nby using characteristic ntemperatures《固体回收燃料–使用特征温度测定灰熔融行为的方法》.pdf
  • BS PD CEN TR 15438-2007 Plastics piping systems — Guidance for coding of products and their intended uses《塑料管路系统 产品及其预期用途的编号导则》.pdf BS PD CEN TR 15438-2007 Plastics piping systems — Guidance for coding of products and their intended uses《塑料管路系统 产品及其预期用途的编号导则》.pdf
  • BS PD CEN TR 15459-2-2017 Energy performance of buildings Economic evaluation procedure for energy systems in buildings Explanation and justification of EN 15459-1 Module .pdf BS PD CEN TR 15459-2-2017 Energy performance of buildings Economic evaluation procedure for energy systems in buildings Explanation and justification of EN 15459-1 Module .pdf
  • BS PD CEN TR 15463-2007 Characterization of sludges Physical consistency Thixotropic behaviour and piling behaviour《淤泥的特性 物理粘合性、触变性能和堆叠性能》.pdf BS PD CEN TR 15463-2007 Characterization of sludges Physical consistency Thixotropic behaviour and piling behaviour《淤泥的特性 物理粘合性、触变性能和堆叠性能》.pdf
  • BS PD CEN TR 15473-2007 Characterization of sludges — Good practice for sludges ndrying《淤泥特性 淤泥烘干用良好实施规程》.pdf BS PD CEN TR 15473-2007 Characterization of sludges — Good practice for sludges ndrying《淤泥特性 淤泥烘干用良好实施规程》.pdf
  • BS PD CEN TR 15500-2-2016 Energy Performance of Buildings Control for heating ventilating and air-conditioning applications Accompanying TR prEN 15500-1 2015 Modules M3-5 .pdf BS PD CEN TR 15500-2-2016 Energy Performance of Buildings Control for heating ventilating and air-conditioning applications Accompanying TR prEN 15500-1 2015 Modules M3-5 .pdf
  • 相关搜索

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

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