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

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

1、国家二级 C语言机试(操作题)模拟试卷 207及答案与解析 一、程序填空题 1 给定程序中,函数 fun的功能是:将形参 s所指字符串中的数字字符转换成对应的数值,计算出这些数值的累加和作为函数值返回。 例如,形参 S所指的字符串为 abs5def126jkm8,程序执行后的输出结果为 22。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:部分源程序在文件 BLANK1 C中。 不得增行或删行,也不得更改程序的结构 ! 试题程序: 1 #include stdio h 2 #include string h 3 #include ctype h 4 int fu

2、n(char*s) 5 int sum=0; 6 while(*s) 7 *found* 8 if(isdigit(*s) 9 sum+=* s-【 1】 ; 10 * found* 11 【 2】 ; 12 13 *found* 14 return【 3】 ; 15 16 main() 17 char s81; int n; 18 printf( nEnter a string: n n); 19 gets(s); 20 n=fun(s); 21 printf( nThe result is: d n n, n); 22 二、程序修改题 2 下列给定程序中,函数 fun和 funx的功能是:

3、用二分法求方程 2x3-4x2+3x-6=0的一个 根,并要求绝对误差不超过 0 001。 例如,若给 m输入 -100,给 n输入 90,则函数求得的一个根为 2 000。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构 ! 试题程序: 1 #include stdio h 2 #include math h 3 double funx(double x) 4 5 return (2*x*x*x-4*x*x+3*x-6); 6 7 double fun(double m, double n) 8 9 *found* 10 int

4、 r; 11 r=(m+n) 2; 12 *found* 13 while(fabs(n-m) 三、程序设计题 3 函数 fun的功能是:将 a、 b中的两个正整数合并形成一个新的整数放在 c中。合并的方式是:将 a中的十位和个位数依次放在变量 e的十位和千位上, b中的十位和个位数依次放在变量 c的个位和百位上。 例如,当 a=45, b=12。调用该函数后, c=5241。 注意:部分源程序在文件 PROG1 C中。 请勿改动 main函数和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 试题程序: 1 #include stdio h 2 void fun(int

5、 a, int b, long*c) 3 4 5 6 main() 7 int a, b; long c; void NONO(); 8 printf(Input a, b: ); 9 scanf( d d, a, b); 10 fun(a, b, c); 11 printf(The result is: ld n, c); 12 NONO(); 13 14 void NONO() 15 *本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 * 16 FILE * rf, *wf ; 17 int i, a, b; long c; 18 rf=fopen(in dat, r); 19

6、 wf=fopen(out dat, w); 20 for(i=0; i0 001) 【试题解析】 (1)程序中会发现 r=(m+n) 2,而 m和 n都是 double型的,并且根据题意可知,变量 r需要定义为 double型。 (2)绝对误差不超过 0 001,所以循环条件应为 fabs(n-m)0 001。 三、程序设计题 3 【正确答案】 1 void fun(int a, int b, long*c) 2 3 *c=(a 10)*1000+(b 10)*100+(a 10)*10+(b 10); 4 【试题解析】 本题是给出两个两位数的正整数分别取出各位上的数字,再按条件组成一个新数。取 a十位数字的方法 a 10,取 a个位数字的方法 a 10。同理可取出整数 b的个位数和十 位数。

展开阅读全文
相关资源
猜你喜欢
  • ASHRAE LO-09-062-2009 Evaluation of Typical Weather Year Selection Approaches for Energy Analysis of Buildings《建筑物能源分析用典型气象年选择方法的评估》.pdf ASHRAE LO-09-062-2009 Evaluation of Typical Weather Year Selection Approaches for Energy Analysis of Buildings《建筑物能源分析用典型气象年选择方法的评估》.pdf
  • ASHRAE LO-09-063-2009 Experimental Investigation of Orbiting Thrust Bearing Using Wide and Shallow Circular Pockets《带有宽浅圆形油盘的轨道推力轴承的实验调查》.pdf ASHRAE LO-09-063-2009 Experimental Investigation of Orbiting Thrust Bearing Using Wide and Shallow Circular Pockets《带有宽浅圆形油盘的轨道推力轴承的实验调查》.pdf
  • ASHRAE LO-09-064-2009 Experimental Measurement and Uncertainty Analysis on the Energy Performance of a Chilled Water Cooling Coil《冷却水冷冻线圈能量性能的实验测量和不确定度分析》.pdf ASHRAE LO-09-064-2009 Experimental Measurement and Uncertainty Analysis on the Energy Performance of a Chilled Water Cooling Coil《冷却水冷冻线圈能量性能的实验测量和不确定度分析》.pdf
  • ASHRAE LO-09-065-2009 Experimental Measurements of a Run-Around Membrane Energy Exchanger (RAMEE) with Comparison to a Numerical Model《带有数值比较模型的环路隔膜能量交换器 (RAMEE)的实验测量》.pdf ASHRAE LO-09-065-2009 Experimental Measurements of a Run-Around Membrane Energy Exchanger (RAMEE) with Comparison to a Numerical Model《带有数值比较模型的环路隔膜能量交换器 (RAMEE)的实验测量》.pdf
  • ASHRAE LO-09-067-2009 Field Measurements of Innovative Indoor Shading Systems in a Full-Scale Office Testbed《办公室全方位现场实测创新的室内遮阳体系测试》.pdf ASHRAE LO-09-067-2009 Field Measurements of Innovative Indoor Shading Systems in a Full-Scale Office Testbed《办公室全方位现场实测创新的室内遮阳体系测试》.pdf
  • ASHRAE LO-09-068-2009 Field Studies in the United States and United Kingdom of the Effectiveness of Mechanical Ventilation Systems on Indoor Air Quality in Hospitality Venues where.pdf ASHRAE LO-09-068-2009 Field Studies in the United States and United Kingdom of the Effectiveness of Mechanical Ventilation Systems on Indoor Air Quality in Hospitality Venues where.pdf
  • ASHRAE LO-09-069-2009 Frost Accumulation Control on an Upward-Facing Horizontal Flat Plate Using Electric Field《使用电场的上表面水平平板的结霜量控制》.pdf ASHRAE LO-09-069-2009 Frost Accumulation Control on an Upward-Facing Horizontal Flat Plate Using Electric Field《使用电场的上表面水平平板的结霜量控制》.pdf
  • ASHRAE LO-09-070-2009 Functional Exergy Efficiency at Near-Environmental Temperatures《近环境温度下的功能性火用效率》.pdf ASHRAE LO-09-070-2009 Functional Exergy Efficiency at Near-Environmental Temperatures《近环境温度下的功能性火用效率》.pdf
  • ASHRAE LO-09-071-2009 Improving Control and Operation of a Single Duct VAV System through CCLEP《通过CCLEP提高控制与操作单管可变空气量系统》.pdf ASHRAE LO-09-071-2009 Improving Control and Operation of a Single Duct VAV System through CCLEP《通过CCLEP提高控制与操作单管可变空气量系统》.pdf
  • 相关搜索

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

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