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

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

1、二级 C 语言-94 及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序中,函数 fun 的功能是计算形参 x 所指数组中 N 个数的平均值(规定所有数均为正数),作为函数值返回;并将大于平均值的数放在形参 y 所指数组中,在主函数中输出。 例如,有 10 个正数:46 30 32 40 6 17 45 15 48 26,平均值为 30.500000。 主函数中输出:46 32 40 45 48。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增

2、行或删行,也不得更改程序的结构! 给定源程序如下。 #includestdlib.h #includestdio.h #define N 10 double fun(double x,double*y) int i,j;double av; /*found*/ av= 1; /*found*/ for(i=0;iN;i+)av=av+ 2; for(i=j=0;iN;i+) /*found*/ if(xiav)y 3=xi; yj=-1; return av; main() int i;double xN= 46,30,32,40,6,17,45,15,48,26; double yN; fo

3、r(i=0;iN;i+)printf(“%4.0f“,xi); printf(“/n“); printf(“/nThe average is:%f/n“,fun(x,y); for(i=0;yi=0;i+)printf(“%5.0f“,yi); printf(“/n“); (分数:30.00)二、程序改错题(总题数:1,分数:30.00)2.给定程序 MODI1.C 中函数 fun 的功能是根据整型形参 m,计算如下公式的值。 (分数:30.00)三、程序设计题(总题数:1,分数:40.00)3.已知学生的记录由学号和学习成绩构成,N 名学生的数据已存入 a 结构体数组中。请编写函数 fun,

4、函数的功能是找出成绩最低的学生记录,通过形参返回主函数(规定只有一个最低分)。 注意:部分源程序存在文件 PROG1.C 中。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入编写的若干语句。 给定源程序如下。 #includestdio.h #includestring.h #define N 10 typedef struct ss char num10;int s;STU; void fun( STU a,STU*s) main() STU aN=“A01“,81,“A02“,89,“A03“,66, “A04“,87,“A05“,77,“A06“,90

5、A07“,79, “A08“,61,“A09“,80,“A10“,71,m; int i; printf(“*The original data*/n“); for(i=0;iN;i+) printf(“No=%s Mark=%d/n“,ai.num,ai.s); fun (a, printf(“*THE RESULT*/n“); printf(“The lowest:%s,%d/n“,m.num,m.s); (分数:40.00)_二级 C 语言-94 答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序中,函数 fun 的功能是计

6、算形参 x 所指数组中 N 个数的平均值(规定所有数均为正数),作为函数值返回;并将大于平均值的数放在形参 y 所指数组中,在主函数中输出。 例如,有 10 个正数:46 30 32 40 6 17 45 15 48 26,平均值为 30.500000。 主函数中输出:46 32 40 45 48。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构! 给定源程序如下。 #includestdlib.h #includestdio.h #define N 10 double fu

7、n(double x,double*y) int i,j;double av; /*found*/ av= 1; /*found*/ for(i=0;iN;i+)av=av+ 2; for(i=j=0;iN;i+) /*found*/ if(xiav)y 3=xi; yj=-1; return av; main() int i;double xN= 46,30,32,40,6,17,45,15,48,26; double yN; for(i=0;iN;i+)printf(“%4.0f“,xi); printf(“/n“); printf(“/nThe average is:%f/n“,fun(

8、x,y); for(i=0;yi=0;i+)printf(“%5.0f“,yi); printf(“/n“); (分数:30.00)解析:0.0 xi/N j+ 解析 填空 1:通过读上面的程序可以看出此空考的是给变量赋初值,av 代表的是平均值,因此 av 的初值应该是 0.0。 填空 2:通过 for 循环可知,此空代表求平均值,因此应该填写 xi/N。 填空 3:先把大于平均值的数放在形参 y 所指数组中,然后使下标值加 1,因此此空应该填 j+。二、程序改错题(总题数:1,分数:30.00)2.给定程序 MODI1.C 中函数 fun 的功能是根据整型形参 m,计算如下公式的值。 (分

9、数:30.00)解析:double fun(int m) for(i=100;i=m;i+=100) 解析 题目要求在函数 fun 中求级数前 m 项和,可用循环语句,每次计算级数中的一项,然后累加。第一处错误在于定义 fun(int m),由函数的返回值可知应该定义为 double fun(int m)。 for(i=100,i=m,i+=100)中是一个简单的语法错误。for 循环语句的形式为 for(表达式 1;表达式 2;表达式 3),其表达式之间应以“;”相隔。三、程序设计题(总题数:1,分数:40.00)3.已知学生的记录由学号和学习成绩构成,N 名学生的数据已存入 a 结构体数组

10、中。请编写函数 fun,函数的功能是找出成绩最低的学生记录,通过形参返回主函数(规定只有一个最低分)。 注意:部分源程序存在文件 PROG1.C 中。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入编写的若干语句。 给定源程序如下。 #includestdio.h #includestring.h #define N 10 typedef struct ss char num10;int s;STU; void fun( STU a,STU*s) main() STU aN=“A01“,81,“A02“,89,“A03“,66, “A04“,87,“A05“

11、77,“A06“,90,“A07“,79, “A08“,61,“A09“,80,“A10“,71,m; int i; printf(“*The original data*/n“); for(i=0;iN;i+) printf(“No=%s Mark=%d/n“,ai.num,ai.s); fun (a, printf(“*THE RESULT*/n“); printf(“The lowest:%s,%d/n“,m.num,m.s); (分数:40.00)_正确答案:()解析:fun(STU a,STU*s) int i; *s=a0; for(i=0;iN;i+) if(s-sai.s) *s=ai; 解析 找出结构体数组元素中的最小值。先认为第 1 个值最小,即*s=a0;,如果在循环的过程中发现比第 1 个值更小的,就将指针 s 指向该元素,直到找到最小元素。另外,本题还涉及结构体中的指向运算符,请考生注意。

展开阅读全文
相关资源
猜你喜欢
  • JIS K 7210-1-2014 8750 Plastics -- Determination of the melt mass-flow rate (MFR) and melt volume-flow rate (MVR) of thermoplastics -- Part 1 Standard method《塑料.pdf JIS K 7210-1-2014 8750 Plastics -- Determination of the melt mass-flow rate (MFR) and melt volume-flow rate (MVR) of thermoplastics -- Part 1 Standard method《塑料.pdf
  • JIS K 7210-2-2014 0000 Plastics -- Determination of the melt mass-flow rate (MFR) and melt volume-flow rate (MVR) of thermoplastics -- Part 2 Method for materia.pdf JIS K 7210-2-2014 0000 Plastics -- Determination of the melt mass-flow rate (MFR) and melt volume-flow rate (MVR) of thermoplastics -- Part 2 Method for materia.pdf
  • JIS K 7211-1-2006 Plastics -- Determination of puncture impact behaviour of rigid plastics -- Part 1 Non-instrumented impact testing《塑料 硬质塑料耐冲孔性能的测定 第1部分 非仪器冲击试.pdf JIS K 7211-1-2006 Plastics -- Determination of puncture impact behaviour of rigid plastics -- Part 1 Non-instrumented impact testing《塑料 硬质塑料耐冲孔性能的测定 第1部分 非仪器冲击试.pdf
  • JIS K 7211-2-2006 Plastics -- Determination of puncture impact behaviour of rigid plastics -- Part 2 Instrumented impact testing《塑料 硬质塑料冲孔性能的测定 第2部分 仪器冲击试验》.pdf JIS K 7211-2-2006 Plastics -- Determination of puncture impact behaviour of rigid plastics -- Part 2 Instrumented impact testing《塑料 硬质塑料冲孔性能的测定 第2部分 仪器冲击试验》.pdf
  • JIS K 7212-1999 Plastics -- Determination of thermal stability of thermoplastics -- Oven method《塑料 热塑性塑料热稳定性的测定 烘箱法》.pdf JIS K 7212-1999 Plastics -- Determination of thermal stability of thermoplastics -- Oven method《塑料 热塑性塑料热稳定性的测定 烘箱法》.pdf
  • JIS K 7216-1980 Testing method for brittleness temperature of plastics《塑料脆化温度的测试方法》.pdf JIS K 7216-1980 Testing method for brittleness temperature of plastics《塑料脆化温度的测试方法》.pdf
  • JIS K 7219-1=2011 5625 Plastics -- Methods of exposure to solar radiation -- Part 1 General guidance《塑料 日光照射暴露法 第1部分 一般指南》.pdf JIS K 7219-1=2011 5625 Plastics -- Methods of exposure to solar radiation -- Part 1 General guidance《塑料 日光照射暴露法 第1部分 一般指南》.pdf
  • JIS K 7219-2-2011 6250 Plastics -- Methods of exposure to solar radiation -- Part 2 Direct weathering and exposure behind window glass《塑料 日光照射暴露法 第2部分 直接风化和窗玻璃后.pdf JIS K 7219-2-2011 6250 Plastics -- Methods of exposure to solar radiation -- Part 2 Direct weathering and exposure behind window glass《塑料 日光照射暴露法 第2部分 直接风化和窗玻璃后.pdf
  • JIS K 7220-2006 Rigid cellular plastics -- Determination of compression properties《硬质泡沫塑料 压缩性能的测定》.pdf JIS K 7220-2006 Rigid cellular plastics -- Determination of compression properties《硬质泡沫塑料 压缩性能的测定》.pdf
  • 相关搜索

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

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