【计算机类职业资格】计算机二级(C)上机考试14及答案解析.doc

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

1、计算机二级(C)上机考试 14 及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main 函数,该函数的功能是:从字符串 str 中取出所有数字字符,并分别计数,然后把结果保存在数组 b 中并输出,把其他字符保存在 b10中。 例如:当 str1=“ab123456789cde090”时,结果为: 0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #inc

2、lude #include main() int i,b11; char *str=“ab123456789cde090“; char *p=str; clrscr(); printf(“* the origial data */n“); puts(str); for(i=0;i_2.改错题 下列给定程序中,函数 fun()的功能是:从 n 个学生的成绩中统计出高于平均分的学生人数,人数由函数值返回,平均分存放在形参 aver 所指的存储单元中。例如输入 8 名学生的成绩: 85 65.5 69 95.5 87 55 62.5 75 则高于平均分的学生人数为 4(平均分为 74.312500)

3、 请改正程序中的错误,使它能得到正确结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构。 试题程序:#include #include #define N 20 int fun(float *s, int n,float *aver) /*found*/ int ave ,t=0; int count=0,k,i; for(k=0;k_3.编程题 下列程序定义了 NN 的二维数组,并在主函数中自动赋值。请编写函数 fun(int aN),该函数的功能是:使数组右上半三角元素中的值全部置成 0。例如 a 数组中的值为 a=4 5 6 1 7 9 3 2 6, 则返回主

4、程序后 a 数组中的值应为 0 0 0 1 0 0 3 2 0 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。 试题程序: #include #include #include #define N 5 int fun (int aN) main() int aNN,i,j; clrscr(); printf(“*The array*/n“); for(i=0;i_计算机二级(C)上机考试 14 答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main 函数,该函数的功能是:从字符串 str

5、 中取出所有数字字符,并分别计数,然后把结果保存在数组 b 中并输出,把其他字符保存在 b10中。 例如:当 str1=“ab123456789cde090”时,结果为: 0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #include main() int i,b11; char *str=“ab123456789cde090“; char *p=str; c

6、lrscr(); printf(“* the origial data */n“); puts(str); for(i=0;i_正确答案:(【1】*p 【2】default: b10+; 【3】p+; )解析:填空 1:根据 switch 语句中 case 后面的常量表达式,可以看出,switch 后面括号中的表达式应该是字符串 str 中的各字符,而指针 p 就是指向字符串 str。填空 2:和各个 case 后面的常量表达式不匹配的都属于其他字符,保存在 b10中。填空 3:指针 p 指向字符串 str,通过 p 自加 1 来移动指针,访问字符串中的所有字符。2.改错题 下列给定程序中,函

7、数 fun()的功能是:从 n 个学生的成绩中统计出高于平均分的学生人数,人数由函数值返回,平均分存放在形参 aver 所指的存储单元中。例如输入 8 名学生的成绩: 85 65.5 69 95.5 87 55 62.5 75 则高于平均分的学生人数为 4(平均分为 74.312500)。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构。 试题程序:#include #include #define N 20 int fun(float *s, int n,float *aver) /*found*/ int ave ,t=0;

8、int count=0,k,i; for(k=0;k_正确答案:((1)错误:int ave ,t=0; 正确:float ave ,t=0.0; (2)错误:if(siave) (3)错误:aver=ave; 正确:*aver=ave; )解析:错误 1:ave 和 t 分别用来存放成绩的平均值和总分,应为实型数。 错误 2:根据题意,找出高于平均分的数,所以此处的关系运算符应为“ 错误 3:aver 是指针,而 ave 是一个数,不能将一个数赋值给一个指针,而要用符号*。 3.编程题 下列程序定义了 NN 的二维数组,并在主函数中自动赋值。请编写函数 fun(int aN),该函数的功能是

9、使数组右上半三角元素中的值全部置成 0。例如 a 数组中的值为 a=4 5 6 1 7 9 3 2 6, 则返回主程序后 a 数组中的值应为 0 0 0 1 0 0 3 2 0 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。 试题程序: #include #include #include #define N 5 int fun (int aN) main() int aNN,i,j; clrscr(); printf(“*The array*/n“); for(i=0;i_正确答案:(int fun (int aN) int i,j; for(i=0;i解析:本题旨在考查控制数组中右上半三角元素的算法,也就是两个千篇一律的循环语句,希望学习者能够掌握消化。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 15154-1-2006 Emergency safety showers - Part 1 Plumbed-in body showers for laboratories English version of DIN EN 15154-1 2006-12《安全性应急冲洗器 第1部分 实验室用垂直人体冲洗洗 DIN EN 15154-1 20.pdf DIN EN 15154-1-2006 Emergency safety showers - Part 1 Plumbed-in body showers for laboratories English version of DIN EN 15154-1 2006-12《安全性应急冲洗器 第1部分 实验室用垂直人体冲洗洗 DIN EN 15154-1 20.pdf
  • DIN EN 15154-2-2006 Emergency safety showers - Part 2 Plumbed-in eye wash units English version of DIN EN 15154-2 2006-12《安全性应急冲洗器 第2部分 眼睛垂直冲洗器 英文版本 DIN EN 15154-2 2006-12》.pdf DIN EN 15154-2-2006 Emergency safety showers - Part 2 Plumbed-in eye wash units English version of DIN EN 15154-2 2006-12《安全性应急冲洗器 第2部分 眼睛垂直冲洗器 英文版本 DIN EN 15154-2 2006-12》.pdf
  • DIN EN 15154-3-2009 Emergency safety showers - Part 3 Non plumbed-in body showers English version of DIN EN 15154-3 2009-07《紧急安全性淋浴 第3部分 非接入式身体淋浴 英文版本DIN EN 15154-3-2009-07》.pdf DIN EN 15154-3-2009 Emergency safety showers - Part 3 Non plumbed-in body showers English version of DIN EN 15154-3 2009-07《紧急安全性淋浴 第3部分 非接入式身体淋浴 英文版本DIN EN 15154-3-2009-07》.pdf
  • DIN EN 15154-4-2009 Emergency safety showers - Part 4 Non plumbed-in eyewash units English version of DIN EN 15154-4 2009-07《紧急安全性淋浴 第4部分 非接入式洗眼器 英文版本DIN EN 15154-4-2009-07》.pdf DIN EN 15154-4-2009 Emergency safety showers - Part 4 Non plumbed-in eyewash units English version of DIN EN 15154-4 2009-07《紧急安全性淋浴 第4部分 非接入式洗眼器 英文版本DIN EN 15154-4-2009-07》.pdf
  • DIN EN 15158-2006 Advanced technical ceramics - Mechanical properties of ceramic composites at high temperature under inert atmosphere - Determination of fatigue properties at cons.pdf DIN EN 15158-2006 Advanced technical ceramics - Mechanical properties of ceramic composites at high temperature under inert atmosphere - Determination of fatigue properties at cons.pdf
  • DIN EN 1516-2000 Surfaces for sports areas - Determination of resistance to indentation German version EN 1516 1999《运动场地面 耐压痕性能测定》.pdf DIN EN 1516-2000 Surfaces for sports areas - Determination of resistance to indentation German version EN 1516 1999《运动场地面 耐压痕性能测定》.pdf
  • DIN EN 15161-2007 Water conditioning equipment inside buildings - Installation operation maintenance and repair English version of DIN EN 15161 2007-02《建筑物内水调节设备 安全、操作、维护和修理》.pdf DIN EN 15161-2007 Water conditioning equipment inside buildings - Installation operation maintenance and repair English version of DIN EN 15161 2007-02《建筑物内水调节设备 安全、操作、维护和修理》.pdf
  • DIN EN 15162-2008 Machines and plants for mining and tooling of natural stone - Safety requirements for gang saws English version of DIN EN 15162 2008-10《天然石的开采和加工用机械和设备 直锯的安全要求》.pdf DIN EN 15162-2008 Machines and plants for mining and tooling of natural stone - Safety requirements for gang saws English version of DIN EN 15162 2008-10《天然石的开采和加工用机械和设备 直锯的安全要求》.pdf
  • DIN EN 15164-2008 Machines and plants for mining and tooling of natural stone - Safety - Requirements for chain- and belt-slotting machines English version of DIN EN 15164 2008-09《.pdf DIN EN 15164-2008 Machines and plants for mining and tooling of natural stone - Safety - Requirements for chain- and belt-slotting machines English version of DIN EN 15164 2008-09《.pdf
  • 相关搜索

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

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