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

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

1、国家二级( C语言)机试模拟试卷 176及答案与解析 一、程序填空题( 30分) 1 用筛选法可得到 2 n(n int fun(int n) int a10000, i, j, count=0; for(i=2; i0;j-)/*found*/ aaj=aj-1; a0=k; for(m=0; m 三、程序设计题( 40分) 3 请编写函 数 fun,函数的功能是求出二维数组周边元素之和,作 为函数值返回。二维数组中的值在主函数中赋予。 例如:二维数组中的值为: 则函数值为 61。 注意:部分源程序存在文件 PROGl C文件中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 f

2、un的花括号中填入你编写的若干语句。 #include#define M 4#define N 5int fun(int aMN)main()int aaMN=(1, 3, 5, 7, 9), 2, 9,9, 9, 4, 6, 9, 9, 9, 8, 1, 3, 5, 7, 0; int i, j, y; void NONO(); printf(“The original data is: n“); for(i=0; i 国家二级( C语言)机试模拟试卷 176答案与解析 一、程序填空题( 30分) 1 【正确答案】 (1)ai (2)ai (3)0 【试题解析】 第一空:循环 “for(j=

3、ai*2; j=n; j+= 【 1】 )“中,循环变量 j的初始值从 ai的 2倍开始,下一次进入循环 j就是 ai的 3倍,第一空处是补充 j的变化情况,而 j每次都增加一个 ai,即第一空处应为 “ai“。 第二空:根据题意第二空处是从数表中找下一个非 0数,即在循环中比较 ai是否为,如果为 0的话, i+指向后一个数表元素,故第二空处应为 “ai“。 第三空:根据语句 “ count+; printf(count 15?“ 5d“:“n 5d“, ai); “可知在满足条件之后计数变量 count自增,并且输出 ai,可知 ai是一个素数,由审题分析可知,经过筛选之后数表中非 0的元

4、素就是素数,故第三空处应为“0“,即 ai不为 0的话就是素数。 二、程序修改题( 30分) 2 【正确答案】 void fun(int *a) aj=aj-1; 【试题解析】 ( 1)主函数中 a为数组名,传过去的形参应该是数组地址。因此, fun函数中的形参不能为整型,所以将 “void fun(int a)”改为 “void fun(int *a)”。 ( 2)第二个标识下 “aaj=aj-1; ”变量 aa没有定义,编译时会提示出错。根据题意, “k=aM-1;”语句是每一行的第一个值,第二个标识下的循环过程中的逻辑关系应该是前一个值赋值给当前值的后一个值。因此第二个标识下 “aaj=aj-1;”应该改为 “aj=aj-1;”。 三、程序设计题( 40分) 3 【正确答案】 int tot=0, i, j; for(i=O; iN; i+) tot+=a0i; tot+=aM一 1i; for(i=1; iM 1; i+) tot+=ai0; tot+=aiN一 1; return tot; 【试题解析】 进入 fun函数,根据前面的分析:求周边元素的和,可以采用两个循环分别把行元素和列元素相加。但 要避免把周边元素重复相加。

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