【计算机类职业资格】二级C语言-352及答案解析.doc

上传人:proposalcash356 文档编号:1325273 上传时间:2019-10-17 格式:DOC 页数:4 大小:35.50KB
下载 相关 举报
【计算机类职业资格】二级C语言-352及答案解析.doc_第1页
第1页 / 共4页
【计算机类职业资格】二级C语言-352及答案解析.doc_第2页
第2页 / 共4页
【计算机类职业资格】二级C语言-352及答案解析.doc_第3页
第3页 / 共4页
【计算机类职业资格】二级C语言-352及答案解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、二级 C 语言-352 及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的学号、姓名和 3 门课的成绩。函数 modify 的功能是将该学生的各科成绩都乘以一个系数 a。 请在程序的下划线处填入正确的内容,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #includestdio.h typedef struct int num; char name9; float score3; STU; void show(STU tt

2、) int i; printf(“%d %s:“,tt.num.tt.name); for(i=0;i3;i+) printf(“%5.1“,tt.scorei); printf(“/n“); /*found*/ void modify( 1*ss,float a) int i; for(i=0;i3;i+) /*found*/ ss- 2;*=a; main() STU std=1,“Zhanghua“,76.5,78.0,82.0; float a; printf(“/nThe original number and nameand scores:/n“); show(std); prin

3、tf(“/nInput a number:“); scanf(“%f“, /*found*/ modify( 3,a); printf(“/nA result of modifying:/n“); show(std); (分数:30.00)二、程序改错题(总题数:1,分数:30.00)2.下列给定程序中,函数 fun 的功能是:求 k!(k13),所求阶乘的值作为函数值返回。例如,若 k=10,则应输出 3628800。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 试题程序: #includeconio.h #includ

4、estdio.h long fun(int k) /*found*/ if k1 return(k*fun(k-1); return 1; main() int k=10; printf(“%d!=%ld/n“,k,fun(k); (分数:30.00)三、程序设计题(总题数:1,分数:40.00)3.程序定义了 NN 的二维数组,并在主函数中自动赋值。请编写函数 fun(int aN, int n),该函数的功能是:使数组左下半三角元素中的值乘以 n。例如,若 n 的值为 3,a 数组中的值为: 则返回主程序后 a 数组中的值应为: (分数:40.00)_二级 C 语言-352 答案解析(总分

5、100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的学号、姓名和 3 门课的成绩。函数 modify 的功能是将该学生的各科成绩都乘以一个系数 a。 请在程序的下划线处填入正确的内容,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #includestdio.h typedef struct int num; char name9; float score3; STU; void show(STU tt) int i; printf(“%d

6、s:“,tt.num.tt.name); for(i=0;i3;i+) printf(“%5.1“,tt.scorei); printf(“/n“); /*found*/ void modify( 1*ss,float a) int i; for(i=0;i3;i+) /*found*/ ss- 2;*=a; main() STU std=1,“Zhanghua“,76.5,78.0,82.0; float a; printf(“/nThe original number and nameand scores:/n“); show(std); printf(“/nInput a number

7、); scanf(“%f“, /*found*/ modify( 3,a); printf(“/nA result of modifying:/n“); show(std); (分数:30.00)解析:(1)STU (2)scorei (3) printf(“%d!=%ld/n“,k,fun(k); (分数:30.00)解析:if(k1)解析 语法错误,if 条件表达式应写在小括号内。三、程序设计题(总题数:1,分数:40.00)3.程序定义了 NN 的二维数组,并在主函数中自动赋值。请编写函数 fun(int aN, int n),该函数的功能是:使数组左下半三角元素中的值乘以 n。例如,若 n 的值为 3,a 数组中的值为: 则返回主程序后 a 数组中的值应为: (分数:40.00)_正确答案:()解析:void fun(int aN, int n) int i,j; for(i=0;iN;i+) for(j=0;j=i;j+) aij=aij*n; 解析 首先从数组中找出要被乘以 n 的那部分元素,这一过程其实就是找出将被挑出的元素在原数组中的分布规律的过程。通过观察得出,要被处理的元素下标值的范围是每行中从第一个元素开始,直到列数等于该行行数时为止。找到这个规律后,依次从数组中取得符合要求的元素,然后乘以 n。

展开阅读全文
相关资源
猜你喜欢
  • EN 15997-2011 en All terrain vehicles (ATVs - Quads) - Safety requirements and test methods (Incorporating corrigendum October 2012)《全地形车辆(ATVs-四边形) 试验方法和安全性要求》.pdf EN 15997-2011 en All terrain vehicles (ATVs - Quads) - Safety requirements and test methods (Incorporating corrigendum October 2012)《全地形车辆(ATVs-四边形) 试验方法和安全性要求》.pdf
  • EN 15998-2010 en Glass in building - Safety in case of fire fire resistance - Glass testing methodology for the purpose of classification《建筑玻璃 火灾安全性 用于分类的玻璃试验方法》.pdf EN 15998-2010 en Glass in building - Safety in case of fire fire resistance - Glass testing methodology for the purpose of classification《建筑玻璃 火灾安全性 用于分类的玻璃试验方法》.pdf
  • EN 15999-1-2014 en Conservation of cultural heritage - Guidelines for design of showcases for exhibition and preservation of objects - Part 1 General requirements《文化遗产的保护 用于展示及保护物体.pdf EN 15999-1-2014 en Conservation of cultural heritage - Guidelines for design of showcases for exhibition and preservation of objects - Part 1 General requirements《文化遗产的保护 用于展示及保护物体.pdf
  • EN 16000-2010 en Plastics piping systems - Systems within the building structure - Mounting and fixing of components in the test apparatus to thermal attack by a single burning ite.pdf EN 16000-2010 en Plastics piping systems - Systems within the building structure - Mounting and fixing of components in the test apparatus to thermal attack by a single burning ite.pdf
  • EN 16002-2010 en Flexible sheets for waterproofing - Determination of the resistance to wind load of mechanically fastened flexible sheets for roof waterproofing《防水柔性板 屋面防水机械固定柔性板的.pdf EN 16002-2010 en Flexible sheets for waterproofing - Determination of the resistance to wind load of mechanically fastened flexible sheets for roof waterproofing《防水柔性板 屋面防水机械固定柔性板的.pdf
  • EN 16003-2011 en Chemicals used for treatment of water intended for human consumption - Calcium magnesium carbonate《用于供人类食用的水处理化学品 碳酸镁》.pdf EN 16003-2011 en Chemicals used for treatment of water intended for human consumption - Calcium magnesium carbonate《用于供人类食用的水处理化学品 碳酸镁》.pdf
  • EN 16004-2011 en Chemicals used for treatment of water intended for human consumption - Magnesium oxide《人类饮用水处理用化学药品 氧化镁》.pdf EN 16004-2011 en Chemicals used for treatment of water intended for human consumption - Magnesium oxide《人类饮用水处理用化学药品 氧化镁》.pdf
  • EN 16005-2012 en Power operated pedestrian doorsets - Safety in use - Requirements and test methods (Incorporating corrigendum August 2015)《门窗操作性能-安全使用要求和测试方法》.pdf EN 16005-2012 en Power operated pedestrian doorsets - Safety in use - Requirements and test methods (Incorporating corrigendum August 2015)《门窗操作性能-安全使用要求和测试方法》.pdf
  • EN 16006-2011 en Animal feeding stuffs - Determination of the Sum of Fumonisin B1 & B2 in compound animal feed with immunoaffinity clean-up and RP-HPLC with fluorescence detection .pdf EN 16006-2011 en Animal feeding stuffs - Determination of the Sum of Fumonisin B1 & B2 in compound animal feed with immunoaffinity clean-up and RP-HPLC with fluorescence detection .pdf
  • 相关搜索

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

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