【计算机类职业资格】国家二级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)在循环中求得每一项,然后对其进行累加求和。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 50289-3-10-2005 Communication cables - Specifications for tests methods - Mechanical test methods - Torsion and twisting《通信电缆 试验方法规范 机械试验方法 扭转》.pdf BS EN 50289-3-10-2005 Communication cables - Specifications for tests methods - Mechanical test methods - Torsion and twisting《通信电缆 试验方法规范 机械试验方法 扭转》.pdf
  • BS EN 50289-3-11-2001 Communication cables - Specifications for test methods - Mechanical test methods - Cable cut-through resistance《通信电缆 试验方法规范 机械试验方法 电缆抗切通性》.pdf BS EN 50289-3-11-2001 Communication cables - Specifications for test methods - Mechanical test methods - Cable cut-through resistance《通信电缆 试验方法规范 机械试验方法 电缆抗切通性》.pdf
  • BS EN 50289-3-12-2001 Communication cables - Specifications for test methods - Mechanical test methods - Shot gun damage《通信电缆 试验方法规范 机械试验方法 强迫性损伤》.pdf BS EN 50289-3-12-2001 Communication cables - Specifications for test methods - Mechanical test methods - Shot gun damage《通信电缆 试验方法规范 机械试验方法 强迫性损伤》.pdf
  • BS EN 50289-3-13-2003 Communication cables - Specifications for test methods - Mechanical test methods - Aeolian vibration《通信电缆 试验方法规范 机械试验方法 风成振动》.pdf BS EN 50289-3-13-2003 Communication cables - Specifications for test methods - Mechanical test methods - Aeolian vibration《通信电缆 试验方法规范 机械试验方法 风成振动》.pdf
  • BS EN 50289-3-15-2003 Communication cables - Specifications for test methods - Mechanical test methods - Underwater cable resistance to hydrostatic pressure《通信电缆 试验方法规范 机械试验方法 海底电缆.pdf BS EN 50289-3-15-2003 Communication cables - Specifications for test methods - Mechanical test methods - Underwater cable resistance to hydrostatic pressure《通信电缆 试验方法规范 机械试验方法 海底电缆.pdf
  • BS EN 50289-3-16-2001 Communication cables - Specifications for test methods - Mechanical test methods - Cable tensile performance《通信电缆 试验方法规范 机械试验方法 电缆抗拉性能》.pdf BS EN 50289-3-16-2001 Communication cables - Specifications for test methods - Mechanical test methods - Cable tensile performance《通信电缆 试验方法规范 机械试验方法 电缆抗拉性能》.pdf
  • BS EN 50289-3-17-2002 Communication cables - Specifications for test methods - Mechanical test methods - Adhesion of dielectric and sheath《通信电缆 试验方法规范 机械试验方法 电介质和护套的粘合性》.pdf BS EN 50289-3-17-2002 Communication cables - Specifications for test methods - Mechanical test methods - Adhesion of dielectric and sheath《通信电缆 试验方法规范 机械试验方法 电介质和护套的粘合性》.pdf
  • BS EN 50289-3-2-2001 Communication cables Specifications for test methods Mechanical test methods Tensile strength and elongation for conductor《通信电缆 试验方法规范 机械试验方法 导体抗拉强度和弹性》.pdf BS EN 50289-3-2-2001 Communication cables Specifications for test methods Mechanical test methods Tensile strength and elongation for conductor《通信电缆 试验方法规范 机械试验方法 导体抗拉强度和弹性》.pdf
  • BS EN 50289-3-4-2001 Communication cables - Specifications for test methods - Mechanical test methods - Tensile strength elongation and shrinkage of insulation and sheath《通信电缆 试验方法.pdf BS EN 50289-3-4-2001 Communication cables - Specifications for test methods - Mechanical test methods - Tensile strength elongation and shrinkage of insulation and sheath《通信电缆 试验方法.pdf
  • 相关搜索

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

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