[计算机类试卷]国家二级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的个位数和十 位数。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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