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

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

1、二级 C语言机试 99及答案解析(总分:100.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:30.00)1.请补充 main函数,该函数的功能是:输出一个 NXN矩阵,要求非周边元素赋值 0,周边元素赋值 1。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。 试题程序: #includestdio .h #define N 10 main() int bbN IN; iht i,j,n; clrscr 0; printf (“ /nInput n: /n“); scanf (“%d“,

2、for (i=0; in; i+ ) for (j=0; jn; j+) if(U【1】/U) bbi j=l; else U【2】/U; printf(“ /n* the result * /n“); for (i=0; in; i+) printf (“ /n/n“); for (j=0; jn; j+) printf (“%4d“,bb i j ); (分数:30.00)填空项 1:_二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中,函数 fun()的功能是:给定 n个实数,输出平均值,并统计平均值以上(含平均值)的实数个数。例如, n=8 时,输入 193.199,1

3、95.673,195.757,196.051,196.092, 196.596,196.579,196.763,所得平均值为 195.838745,在平均值以上的实数个数应为 5。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include conio.h #include stdio.h int fun(float x, int n) /*found*/ iht j, c=0;float xa=0.0; for (j=0; jn;.j+) xa+=xj/n; printf(“ave=%f/n“,xa); fo

4、r (j=0; jn;j+) if(xj=xa) c+; returnc; main() float xl00= 193.199,195.673,195.757, 196.051,196.092,196.596, 196.579,196.763; clrscr (); printf(“%d/n“,fun (x,8); (分数:30.00)填空项 1:_三、B编程题/B(总题数:1,分数:40.00)3.请编写函数 fun(),该函数的功能是:计算 n门课程的平均分,计算结果作为函数值返回。 例如 x有5门课程的成绩是 90.5,72,80,61.5,55,则函数的值为 71.80。 注意:部分

5、源程序给出如下 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。 试题程序:#include stdio.h float fun (float *a, int n) main () float score30=(90.5,72,80,61.5,55, aver; aver=fun(score, 5); printf(“/nAverage score is: %5.2f /n“,aver); (分数:40.00)_二级 C语言机试 99答案解析(总分:100.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:30.00)1.请补充 m

6、ain函数,该函数的功能是:输出一个 NXN矩阵,要求非周边元素赋值 0,周边元素赋值 1。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。 试题程序: #includestdio .h #define N 10 main() int bbN IN; iht i,j,n; clrscr 0; printf (“ /nInput n: /n“); scanf (“%d“, for (i=0; in; i+ ) for (j=0; jn; j+) if(U【1】/U) bbi j=l; else U【2】/U;

7、 printf(“ /n* the result * /n“); for (i=0; in; i+) printf (“ /n/n“); for (j=0; jn; j+) printf (“%4d“,bb i j ); (分数:30.00)填空项 1:_ (正确答案:1i=0i=n-1j=0j=n-1)解析:2bbij=0 解析 填空 1:用二维数组表示 nn矩阵时,周边元素是行下标为 0或 n-1,列下标为。或 n-1的元素,判断时四个条件中只要有一个条件满足,则该元素就是周边元素,所以用“”运算符。填空 2:题目要求将非周边元素赋值为 0。二、B改错题/B(总题数:1,分数:30.00)

8、2.下列给定程序中,函数 fun()的功能是:给定 n个实数,输出平均值,并统计平均值以上(含平均值)的实数个数。例如, n=8 时,输入 193.199,195.673,195.757,196.051,196.092, 196.596,196.579,196.763,所得平均值为 195.838745,在平均值以上的实数个数应为 5。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include conio.h #include stdio.h int fun(float x, int n) /*found*/

9、 iht j, c=0;float xa=0.0; for (j=0; jn;.j+) xa+=xj/n; printf(“ave=%f/n“,xa); for (j=0; jn;j+) if(xj=xa) c+; returnc; main() float xl00= 193.199,195.673,195.757, 196.051,196.092,196.596, 196.579,196.763; clrscr (); printf(“%d/n“,fun (x,8); (分数:30.00)填空项 1:_ (正确答案:错误:缺 正确:加)解析:解析 本题我们可以拆分成两个简单的 c语言试题:

10、 (1)求出 n个数的平均值。 (2)将大于平均值的数字个数计算出来。可利用循环和条件选择语句,对 x数组进行遍历,若某个值大于平均成绩,则将该元素累加计入 c中。我们先来摘清楚一个简单的求 10个整数平均值的例子。 #include “stdio.h“ void main() int i,a10,s=0; float aver=0.0; for (i=0;i三、B编程题/B(总题数:1,分数:40.00)3.请编写函数 fun(),该函数的功能是:计算 n门课程的平均分,计算结果作为函数值返回。 例如 x有5门课程的成绩是 90.5,72,80,61.5,55,则函数的值为 71.80。 注

11、意:部分源程序给出如下 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。 试题程序:#include stdio.h float fun (float *a, int n) main () float score30=(90.5,72,80,61.5,55, aver; aver=fun(score, 5); printf(“/nAverage score is: %5.2f /n“,aver); (分数:40.00)_正确答案:()解析:float fun (float *a, int n) float av=0.0; int i; for(i=0;i

展开阅读全文
相关资源
猜你喜欢
  • JUS M E6 200-1984 Water central heating plants Safety reguirements for lowpressure steam boilers《中央水热式设备 低压蒸汽锅炉要求规范》.pdf JUS M E6 200-1984 Water central heating plants Safety reguirements for lowpressure steam boilers《中央水热式设备 低压蒸汽锅炉要求规范》.pdf
  • JUS M E6 201-1984 Water central heating plants Safety reguirements for hot vvater heating with flow temperatures up to 110C《中央水热设备 超过110摄氏度的水温加热安全要求》.pdf JUS M E6 201-1984 Water central heating plants Safety reguirements for hot vvater heating with flow temperatures up to 110C《中央水热设备 超过110摄氏度的水温加热安全要求》.pdf
  • JUS M E6 202-1984 Water central heating plants Safety requirements for hot vvater heating with flow temperatures up to 110 C up to 350 kl V with termostatic safety protection《中央水热设.pdf JUS M E6 202-1984 Water central heating plants Safety requirements for hot vvater heating with flow temperatures up to 110 C up to 350 kl V with termostatic safety protection《中央水热设.pdf
  • JUS M E6 203-1984 Water central heating plants Hot water heating with flow temperature above 110C and pressure in exess of 0 5 bar overpressure Safety reguirements and assembly《水供暖.pdf JUS M E6 203-1984 Water central heating plants Hot water heating with flow temperature above 110C and pressure in exess of 0 5 bar overpressure Safety reguirements and assembly《水供暖.pdf
  • JUS M E6 204-1991 Safety requirement for heat generating installations with flow temperatures up to 120c closed water heating plants with thermostatic safety requirements with a stof.pdf JUS M E6 204-1991 Safety requirement for heat generating installations with flow temperatures up to 120c closed water heating plants with thermostatic safety requirements with a stof.pdf
  • JUS M E6 205-1984 Water centra! heating plants Expansion tanks《水供暖总站 蒸发器》.pdf JUS M E6 205-1984 Water centra! heating plants Expansion tanks《水供暖总站 蒸发器》.pdf
  • JUS M E6 206-1997 Expansion tanks - Elastomer membranes - Requirements and testing《蒸发器 弹性薄膜 要求和测试》.pdf JUS M E6 206-1997 Expansion tanks - Elastomer membranes - Requirements and testing《蒸发器 弹性薄膜 要求和测试》.pdf
  • JUS M E6 207-1997 Thermostats temperature limiters and thermal cut-offs for heat generating systems safety reauirements and testing《加热系统的温度计、限温器和热断路器:安全要求和测试规范》.pdf JUS M E6 207-1997 Thermostats temperature limiters and thermal cut-offs for heat generating systems safety reauirements and testing《加热系统的温度计、限温器和热断路器:安全要求和测试规范》.pdf
  • JUS M E6 300-1994 Common rules for testing of appliances using gas fuels《燃油器具的一般测试办法》.pdf JUS M E6 300-1994 Common rules for testing of appliances using gas fuels《燃油器具的一般测试办法》.pdf
  • 相关搜索

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

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