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

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

1、二级 C语言机试-64 及答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:33.00)1.请补充函数 fun(),该函数的功能是:计算下面公式的值 (k50): (分数:33.00)填空项 1:_二、改错题(总题数:1,分数:33.00)2.下列给定程序中,函数 fun()的功能是:输出 M行 N列整数方阵,然后求两条对角线上的各元素的平方和,返回此和数。请改正程序中的错误,使它能得到正确结果。注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include conioh#include stdioh#define M 5int

2、fun(int n,int xxM)int i,j,sum=O;printf(“/nThe %d x %d matrix:/n“,M,M);for(i=0;iN;i+)for(j=0;jM;j+)/*found*/printf(“%4d“,xxi j);/*found*/printf(/n);for(i=0;in;i+)sum+=xxii*xxii+xxin-i-1*xxin-i-1;return(sum);main()int aaMM=3,12,4,24,35,11,3, 3,7, 56,61,27,58,49,24,17,28,7,36,85,15,33,5,24,9;clrscr();p

3、rintf(“/nThe result of all elements on 2diagnals iS%d“,fun(M,aa);(分数:33.00)填空项 1:_三、编程题(总题数:1,分数:34.00)3.请编写函数 fun(),其功能是:计算并输出下列多项式值。S(1+1/2)+(1/3+1/4)+(1/(2n1)+l/2n)例如,若主函数从键盘给 n输入 12后,则输出为 S=3.775958。n的值要求大于 1但不大于 100。注意:部分源程序给出如下。请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。试题程序:#includestdio

4、hdouble fun(int n)main()int n;double s;printf(“/nlnput n:“);scanf(“%d“,&n);s=fun(n); printf(“/ns=%f/n“,s);(分数:34.00)_二级 C语言机试-64 答案解析(总分:100.00,做题时间:90 分钟)一、填空题(总题数:1,分数:33.00)1.请补充函数 fun(),该函数的功能是:计算下面公式的值 (k50): (分数:33.00)填空项 1:_ (正确答案:1 1 2 k=n 3s*=f/p)解析:解析 填空 1:变量 s存放最后的计算结果,由公式可知,计算结果为多个数的乘积,所

5、以 s应该初始化为 1。填空 2: for 循环的次数为 n,由公式可知,k 的取值应该从 1到 n。填空 3:for 循环求出的 f为(2k-1)2k+l,for 循环求出的 p为(2k +1)2k-1,由公式可知,每项即为 f/p,所以此处应填s*=f/p。二、改错题(总题数:1,分数:33.00)2.下列给定程序中,函数 fun()的功能是:输出 M行 N列整数方阵,然后求两条对角线上的各元素的平方和,返回此和数。请改正程序中的错误,使它能得到正确结果。注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include conioh#include stdio

6、h#define M 5int fun(int n,int xxM)int i,j,sum=O;printf(“/nThe %d x %d matrix:/n“,M,M);for(i=0;iN;i+)for(j=0;jM;j+)/*found*/printf(“%4d“,xxi j);/*found*/printf(/n);for(i=0;in;i+)sum+=xxii*xxii+xxin-i-1*xxin-i-1;return(sum);main()int aaMM=3,12,4,24,35,11,3, 3,7, 56,61,27,58,49,24,17,28,7,36,85,15,33,5

7、24,9;clrscr();printf(“/nThe result of all elements on 2diagnals iS%d“,fun(M,aa);(分数:33.00)填空项 1:_ (正确答案:(1)错误:printf(“%4d“,xxij); 正确:printf(“%4d“,xxij):(2) 错误:printf(/n); 正确:printr(“/n“);)解析:解析 错误 1:此处考查的是对二维数组的引用方法。错误 2:此处考查的是输出语句的语法,括号中应该用双引号,而不是单引号。三、编程题(总题数:1,分数:34.00)3.请编写函数 fun(),其功能是:计算并输出下列

8、多项式值。S(1+1/2)+(1/3+1/4)+(1/(2n1)+l/2n)例如,若主函数从键盘给 n输入 12后,则输出为 S=3.775958。n的值要求大于 1但不大于 100。注意:部分源程序给出如下。请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。试题程序:#includestdiohdouble fun(int n)main()int n;double s;printf(“/nlnput n:“);scanf(“%d“,&n);s=fun(n); printf(“/ns=%f/n“,s);(分数:34.00)_正确答案:(double fun(int n) int i;double s=0.0;for(i=1;i=n;i+) /*计算 S=(1+l/2)+(1/3+1/4)+(1/(2n-1)+1/2n)*/s=s+(1.0/(2*i-1)+1.0/(2*i);return s;)解析:解析 本题中 s=s+(1.0/(2*i-1)+1.0/(2*i);语句是用 C程序去表达题目中的每一项,这是关键,其他问题不难理解。

展开阅读全文
相关资源
猜你喜欢
  • ETSI TS 125 420-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V13 0 0 3GPP TS 25 420 version 13 0 0 Release 13)《通用移动通信系.pdf ETSI TS 125 420-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V13 0 0 3GPP TS 25 420 version 13 0 0 Release 13)《通用移动通信系.pdf
  • ETSI TS 125 420-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V14 0 0 3GPP TS 25 420 version 14 0 0 Release 14)《通用移动通信系.pdf ETSI TS 125 420-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V14 0 0 3GPP TS 25 420 version 14 0 0 Release 14)《通用移动通信系.pdf
  • ETSI TS 125 420-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V15 0 0 3GPP TS 25 420 version 15 0 0 Release 15).pdf ETSI TS 125 420-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface general aspects and principles (V15 0 0 3GPP TS 25 420 version 15 0 0 Release 15).pdf
  • ETSI TS 125 421-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V13 0 0 3GPP TS 25 421 version 13 0 0 Release 13)《通用移动通信系统(UMTS) UTRAN(通用陆地无线接入网.pdf ETSI TS 125 421-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V13 0 0 3GPP TS 25 421 version 13 0 0 Release 13)《通用移动通信系统(UMTS) UTRAN(通用陆地无线接入网.pdf
  • ETSI TS 125 421-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V14 0 0 3GPP TS 25 421 version 14 0 0 Release 14)《通用移动通信系统(UMTS) UTRAN(通用陆地无线接入网.pdf ETSI TS 125 421-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V14 0 0 3GPP TS 25 421 version 14 0 0 Release 14)《通用移动通信系统(UMTS) UTRAN(通用陆地无线接入网.pdf
  • ETSI TS 125 421-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V15 0 0 3GPP TS 25 421 version 15 0 0 Release 15).pdf ETSI TS 125 421-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface layer 1 (V15 0 0 3GPP TS 25 421 version 15 0 0 Release 15).pdf
  • ETSI TS 125 422-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V13 0 0 3GPP TS 25 422 version 13 0 0 Release 13)《通用移动通信系统(UMTS) 通用.pdf ETSI TS 125 422-2016 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V13 0 0 3GPP TS 25 422 version 13 0 0 Release 13)《通用移动通信系统(UMTS) 通用.pdf
  • ETSI TS 125 422-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V14 0 0 3GPP TS 25 422 version 14 0 0 Release 14)《通用移动通信系统(UMTS) UT.pdf ETSI TS 125 422-2017 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V14 0 0 3GPP TS 25 422 version 14 0 0 Release 14)《通用移动通信系统(UMTS) UT.pdf
  • ETSI TS 125 422-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V15 0 0 3GPP TS 25 422 version 15 0 0 Release 15).pdf ETSI TS 125 422-2018 Universal Mobile Telecommunications System (UMTS) UTRAN Iur interface signalling transport (V15 0 0 3GPP TS 25 422 version 15 0 0 Release 15).pdf
  • 相关搜索

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

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