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

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

1、国家二级 C语言机试(操作题)模拟试卷 574及答案与解析 一、程序填空题 1 下列给定程序中,函数 fun的功能是:将 NN矩阵中元素的值按列向右移动 1个位置,右边被移出矩阵的元素绕回左边第 1列。 例如, N=3,有下列矩阵 1 2 3 4 5 6 7 8 9 计算结果为: 3 1 2 6 4 5 9 7 8 请在程序的下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构 ! 试题程序: #include stdio h #define N 4 void fun(int(* t)N) int i, j, x; fo

2、r(i=0; i 【 1】 ; i+) x=ti【 2】 ; for(j=N一 1; j 0; j一一 ) tij=tij一 1; ti【 3】 =x; main() int i, j, tN=21, 12, 13, 24, 25, 16, 47, 38, 29, 11, 32, 54, 42, 21,33, 10; printf(“The orriginal array: n“); for(i=0; i N; i+) for(j=0; j N; j+) printf(“ 2d“, tij); printf(“ n“); fun(t); printf(“nThe result is: n“);

3、 for(i=0 ; i N; i+) for(j=0 ; j N; j+) printf(“ 2d“, tij); printf(“ n“); 二、程序修改题 2 下列给定程序中,函数 fun的功能是:计算并输出下列级数的前 N项和 SN,直到SN+1的值大于 q为止, q的值通过形参传入。 例如,若 q的值为 50 0,则函数值应为 49 394948。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行 ,也不得更改程序的结构 !试题程序: #include conio h #include Stdio h double fun(double q)

4、int n; double s, t; n=2; s=2 0; while(s =q) t=s; *found* s=s+(n+1) n; n+; printf(“n= d n“, n); *found* return s; main() printf(“ f n“, fun(50); 三、程序设计题 3 编写函数 fun,其功能是:求 Fibonacci数列中大于 t的最小的数,结果由函数返回。 Fibonacci数列 F(n)的定义为: F(0)=0, F(1)=1 F(n)=F(n一 1)+F(n一 2) 例如,当 t=1000时,函数值为 1597。 注意:部分源程序给出如下。 请勿改

5、动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 试题程序: #include conio h #include math h #include stdio h int fun(int t) main() int n; n=10 00; printf(“n= d, f= d n“, n, fun(n); 国家二级 C语言机试(操作题)模拟试卷 574答案与解析 一、程序填空题 1 【正确答案】 (1)N (2)N一 1 (3)0 【试题解析】 填空 1:因为是 NN的矩阵,所以行列数是相同的。第一个 for循环用来循环行,因此填入一个循环界限 N。 填

6、空 2:此语句将移出矩阵的元素暂存,移出矩阵的元素的列下标为 N 1,因此填入 N 1。 填 空 3:此语句将移出矩阵的元素放入最左边,也就是第一列,第一列元素的列下标为 0,因此填入 0。 二、程序修改题 2 【正确答案】 (1)s=s+(double)(n+1) n; (2)return t; 【试题解析】 (1)在 C语言中,整数除以整数得出的结果也是整数,因此此处要转换数据类型。 (2)观察 while循环,如果返回变量是 s,那么返回的是大于 q的值,而题中所要返回的是小于 q的值,所以应该返回变量 t。 三、程序设计题 3 【正确答案】 int fun(int t) int f0=0, f1=1, f; do *根据 Fibonacci数列的定义求数值 * f=f0+f1; f0=f1; f1=f; )while(f t); *如果求的数值小于 t则继续 * return f; 【试题解析】 根据所给数列定义不难发现,该数列最终的结果是由两个数列之和组成,所以可以在循环内部始终把 f看成是前两项之和,而 f0始终代表第 n一 2项, n代表第 n一 1项。退出循环时得到的数 f,就是大于指定数的最小的数。

展开阅读全文
相关资源
猜你喜欢
  • 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