【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷348及答案解析.doc

上传人:priceawful190 文档编号:1332162 上传时间:2019-10-17 格式:DOC 页数:3 大小:41KB
下载 相关 举报
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷348及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷348及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷348及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 348及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.函数 fun的功能是:根据所给的年、月、日,计算出该日是这一年的第几天,并作为函数值返回。其中函数 isleap用来判别某一年是否为闰年。 例如,若输入:2008 5 1,则程序输出:2008 年 5月 1日是该年的第 122天。 请在程序的下划线处填入正确的内容,并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1C 中。 不得增行或删行,也不得更改程序的结构!1 #includestdioh2 int isleap

2、int year)3 int leap;4 leap=(year4=0 18 *found*19 t(k)=b(j);20 bjs=0;21 22 return t;23 24 outresult(STU a,FILE *pf)25 int i;26 for(i=0;iN;i+)27 fprintf(pf,No=s Mark=dn,ainum,ais);28 fprintf(pf,nn);29 30 main()31 STU aN=A01,81,A02,89,A03,66,A04,87,A05,77,A06,90,A07,79,A08,61,A09,80,A10,71;32 STU *pOr

3、der;33 int i,m;34 printf(*The Original data*n);35 outresult(a,stdout);36 printf(nGive the number of the students who have better score:);37 scanf(d,m);38 while(m10)39 printf(nGive the number of the students who have better score:);40 scanf(d,m);41 42 porder=fun(a,m);43 printf(* THE RESULT * n);44 pr

4、intf(The top:n);45 for(i=0;im;i+)46 printf(sdn,pOrderinum,pOrderis);47 free(pOrder);48 (分数:2.00)_三、程序设计题(总题数:1,分数:2.00)3.请编写函数 fun,其功能是:计算并输出当 x097 时下列多项式的值,直到S n -S n-1 0000001 为止。 (分数:2.00)_国家二级 C语言机试(操作题)模拟试卷 348答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.函数 fun的功能是:根据所给的年、月、日,计算出该日是这一年的第几天,并

5、作为函数值返回。其中函数 isleap用来判别某一年是否为闰年。 例如,若输入:2008 5 1,则程序输出:2008 年 5月 1日是该年的第 122天。 请在程序的下划线处填入正确的内容,并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1C 中。 不得增行或删行,也不得更改程序的结构!1 #includestdioh2 int isleap(int year)3 int leap;4 leap=(year4=0 18 *found*19 t(k)=b(j);20 bjs=0;21 22 return t;23 24 outresult(STU a,FIL

6、E *pf)25 int i;26 for(i=0;iN;i+)27 fprintf(pf,No=s Mark=dn,ainum,ais);28 fprintf(pf,nn);29 30 main()31 STU aN=A01,81,A02,89,A03,66,A04,87,A05,77,A06,90,A07,79,A08,61,A09,80,A10,71;32 STU *pOrder;33 int i,m;34 printf(*The Original data*n);35 outresult(a,stdout);36 printf(nGive the number of the stude

7、nts who have better score:);37 scanf(d,m);38 while(m10)39 printf(nGive the number of the students who have better score:);40 scanf(d,m);41 42 porder=fun(a,m);43 printf(* THE RESULT * n);44 printf(The top:n);45 for(i=0;im;i+)46 printf(sdn,pOrderinum,pOrderis);47 free(pOrder);48 (分数:2.00)_正确答案:(正确答案:(

8、1)t=(STU *)calloc(sizeof (STU),m); (2)tk=bj;)解析:解析:(1)题干中要求结构体 STU类型的 m个学生放在动态分配的连续存储区中,“t=(STU *)calloc(sizeof( STU),m)”语句没有使用分号“;”结束,因此需要在语句结尾处加分号。calloc 函数是 C语言的动态分配函数,分配存储空间。 (2)第二个标识下是将 b数组拷贝到 t数组,在 C语言中,数组元素的访问使用中括号“”而不是元括弧“()”,因此第二标识下应改成“tk=bj;”。三、程序设计题(总题数:1,分数:2.00)3.请编写函数 fun,其功能是:计算并输出当 x

9、097 时下列多项式的值,直到S n -S n-1 0000001 为止。 (分数:2.00)_正确答案:(正确答案:1 int n=1; *循环计数* 2 double sn=1; *累计数* 3 double xn=1,xn1=0; *x 的 n值,以及 x的 n-1值; * 4 while(fabs(xn-xn1)=0000001)*绝对值是否满足条件* 5 6 xn=xn*x*(05-n+1)n;*表达式分解以后 xn=(xn-i)*x*(05-n+i)n* 7 n+=1; 8 sn+=xn; * sn 累加上 xn* 9 return(sn);)解析:解析:(1)根据题干中给出的数列,推出每一项分子是在前一项分子的基础上乘以(05-n+1)*x,分母则为阶乘,也就是在前一项分母的基础上乘以 n。 (2)在循环中求得每一项,然后对其进行累加求和。

展开阅读全文
相关资源
猜你喜欢
  • ISO 337 CORR 1-1990 Road vehicles 50 semi-trailer fifth wheel coupling pin basic and mounting interchangeability dimensions technical corrigendum 1《道路车辆 半挂车牵引座5.pdf ISO 337 CORR 1-1990 Road vehicles 50 semi-trailer fifth wheel coupling pin basic and mounting interchangeability dimensions technical corrigendum 1《道路车辆 半挂车牵引座5.pdf
  • ISO 337-1981 Road vehicles 50 semi-trailer fifth wheel coupling pin Basic and mounting interchangeability dimensions《道路车辆 半挂车牵引座50号连接销 基本尺寸和装配尺寸、互换性尺寸》.pdf ISO 337-1981 Road vehicles 50 semi-trailer fifth wheel coupling pin Basic and mounting interchangeability dimensions《道路车辆 半挂车牵引座50号连接销 基本尺寸和装配尺寸、互换性尺寸》.pdf
  • ISO 3371-1975 Modular units for machine tool construction Rotary tables and multi-sided centre bases for rotary tables《组合机床通用部件 回转工作台和回转工作台用多边形中间底座》.pdf ISO 3371-1975 Modular units for machine tool construction Rotary tables and multi-sided centre bases for rotary tables《组合机床通用部件 回转工作台和回转工作台用多边形中间底座》.pdf
  • ISO 3375-2009 Textile glass - Determination of stiffness of rovings《纺织玻璃纤维 粗纱硬挺度的测定》.pdf ISO 3375-2009 Textile glass - Determination of stiffness of rovings《纺织玻璃纤维 粗纱硬挺度的测定》.pdf
  • ISO 3384-1-2011 Rubber vulcanized or thermoplastic - Determination of stress relaxation in compression - Part 1 Testing at constant temperature《硫化橡胶或热塑性橡胶 压缩应变力.pdf ISO 3384-1-2011 Rubber vulcanized or thermoplastic - Determination of stress relaxation in compression - Part 1 Testing at constant temperature《硫化橡胶或热塑性橡胶 压缩应变力.pdf
  • ISO 3384-2-2012 Rubber vulcanized or thermoplastic - Determination of stress relaxation in compression - Part 2 Testing with temperature cycling《硫化或热塑性橡胶 常温和高温下.pdf ISO 3384-2-2012 Rubber vulcanized or thermoplastic - Determination of stress relaxation in compression - Part 2 Testing with temperature cycling《硫化或热塑性橡胶 常温和高温下.pdf
  • ISO 3386-1-1986 Polymeric materials cellular flexible Determination of stress-strain characteristics in compression Part 1 Low-density materials《软质泡沫聚合材料 压缩应力应变.pdf ISO 3386-1-1986 Polymeric materials cellular flexible Determination of stress-strain characteristics in compression Part 1 Low-density materials《软质泡沫聚合材料 压缩应力应变.pdf
  • ISO 3386-2-1997 Flexible cellular polymeric materials - Determination of stress-strain characteristics in compression - Part 2 High-density materials《软质泡沫聚合材料 压.pdf ISO 3386-2-1997 Flexible cellular polymeric materials - Determination of stress-strain characteristics in compression - Part 2 High-density materials《软质泡沫聚合材料 压.pdf
  • ISO 3390-1976 Aluminium oxide primarily used for the production of aluminium Determination of manganese content Flame atomic absorption method《主要用于铝生产的氧化铝 锰含量的测.pdf ISO 3390-1976 Aluminium oxide primarily used for the production of aluminium Determination of manganese content Flame atomic absorption method《主要用于铝生产的氧化铝 锰含量的测.pdf
  • 相关搜索

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

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