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

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

1、计算机二级(C)上机考试 3及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main函数,该函数的功能是:从键盘输入一个字符串并保存在字符 str1中,把字符串str1中下标为偶数的字符保存在字符串 str2中并输出。例如,当 str1=“cdefghij”,则str2=“cegi”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #define LEN 80 main() char str1LEN,str2LEN; char *p

2、1=str1,*p2=str2; int i=0,j=0; clrscr(); printf(“Enter the string:/n“); scanf(【1】); printf(“*the origial string*/n“); while(*(p1+j) printf(“【2】“,*(p1+j); j+; for(i=0;i_2.改错题 下列给定程序中,函数 fun()的功能是:读入一个字符串(长度 #include /*found*/ int fun(char t ) char c; int i,j; for(i=0;i_3.编程题 下列程序定义了 NN的二维数组,并在主函数中自动赋值

3、请编写函数 fun(int aN),该函数的功能是:使数组右上半三角元素中的值全部置成 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=

4、0;i_计算机二级(C)上机考试 3答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main函数,该函数的功能是:从键盘输入一个字符串并保存在字符 str1中,把字符串str1中下标为偶数的字符保存在字符串 str2中并输出。例如,当 str1=“cdefghij”,则str2=“cegi”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #define LEN 80 main() char str1LEN,str2LEN; char

5、 *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf(“Enter the string:/n“); scanf(【1】); printf(“*the origial string*/n“); while(*(p1+j) printf(“【2】“,*(p1+j); j+; for(i=0;i_正确答案:(【1】%s,str1 【2】%c 【3】str2 )解析:填空 1:本题考查对标准输入函数 scanf()的调用格式,当输入字符串时,格式控制字符串为%s,题目要求输入的字符串保存在 str1中,所以地址表列应为字符串的首地址,即为 str1。填空

6、 2:本题考查对标准输出函数 printf()的调用格式,当输出为字符型变量时,格式控制字符串为%c。填空 3:题目要求将 str1中下标为偶数的字符保存在字符串 str2中并输出,所以 printf()函数的输出表列是 str2。2.改错题 下列给定程序中,函数 fun()的功能是:读入一个字符串(长度 #include /*found*/ int fun(char t ) char c; int i,j; for(i=0;i_正确答案:((1)错误:int fun(char t ) 正确:void fun(char t ) (2)错误: tj=ti+; 正确:tj=ti; )解析:错误 1

7、该函数只是对一个字符串中的元素进行比较大小的操作,并没有具体的返回值,因此,函数的返回值类型应为 void。 错误 2:本题的思路是利用选择法对数组元素进行比较。所谓选择法,是依次用当前取得的元素和它后面的元素进行比较,在第一个元素和它后面的元素顺次比较时,可以借助中间变量来对两数进行交换,要保证这第一个元素始终存放数组中的最大数,以后依次挑出次大数,这样最终的数组就是有序的。解答本题,只要理解了选择法的思想,找到并改正错误就很容易了。 3.编程题 下列程序定义了 NN的二维数组,并在主函数中自动赋值。请编写函数 fun(int aN),该函数的功能是:使数组右上半三角元素中的值全部置成 0

8、例如 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解析:本题旨在考查控制数组中右上半三角元素的算法,也就是两个千篇一律的循环语句,希望学习者能够掌握消化。

展开阅读全文
相关资源
猜你喜欢
  • DS EN 2332-1993 Aerospace series Textile glass fibre preimpregnates Test method for the determination of the resin flow《航空航天系列 纺织品玻璃纤维预浸渍 测定树脂流量的试验方法》.pdf DS EN 2332-1993 Aerospace series Textile glass fibre preimpregnates Test method for the determination of the resin flow《航空航天系列 纺织品玻璃纤维预浸渍 测定树脂流量的试验方法》.pdf
  • DS EN 234-1993 Wallcoverings in roll form Specification for wallcoverings for subsequent decoration《卷式墙壁饰面 装饰用墙壁饰面规范》.pdf DS EN 234-1993 Wallcoverings in roll form Specification for wallcoverings for subsequent decoration《卷式墙壁饰面 装饰用墙壁饰面规范》.pdf
  • DS EN 2350-1991 Aerospace series Circuit breakers Technical specification《航空与航天 保护开关 交货技术条件》.pdf DS EN 2350-1991 Aerospace series Circuit breakers Technical specification《航空与航天 保护开关 交货技术条件》.pdf
  • DS EN 2374-1991 Aerospace series Glass fibre reinforced mouldings and sandwich composites Production of test panels《航空与航天 玻璃纤维强化的造型材料和夹芯复合材料 检验板的生产》.pdf DS EN 2374-1991 Aerospace series Glass fibre reinforced mouldings and sandwich composites Production of test panels《航空与航天 玻璃纤维强化的造型材料和夹芯复合材料 检验板的生产》.pdf
  • DS EN 2375-1994 Aerospace series-Resin preimpregnated materials-Production batch sampling procedure《航空航天系列 树脂预浸渍材料 生产批次抽样程序》.pdf DS EN 2375-1994 Aerospace series-Resin preimpregnated materials-Production batch sampling procedure《航空航天系列 树脂预浸渍材料 生产批次抽样程序》.pdf
  • DS EN 2381-1992 Aerospace series Aluminium alloy AL-P7009-T7452 Hand forgings 40 mm a 150 mm《航空航天系列 铝合金AL-P7009-T7452 手工锻材40 mm≤a≤150 mm》.pdf DS EN 2381-1992 Aerospace series Aluminium alloy AL-P7009-T7452 Hand forgings 40 mm a 150 mm《航空航天系列 铝合金AL-P7009-T7452 手工锻材40 mm≤a≤150 mm》.pdf
  • DS EN 2384-1992 Aerospace series Aluminium alloy AL-P2014A-T6511 Extruded bars and sections a or D 150 mm《航空航天系列 铝合金AL-P2014A T651 挤压棒材和型材a或D≤150 mm》.pdf DS EN 2384-1992 Aerospace series Aluminium alloy AL-P2014A-T6511 Extruded bars and sections a or D 150 mm《航空航天系列 铝合金AL-P2014A T651 挤压棒材和型材a或D≤150 mm》.pdf
  • DS EN 2385-1992 Aerospace series Aluminium alloy AL-P7009-T74511 Extruded bars and sections a or D 125 mm《航空航天系列 铝合金AL-P7009-T74511 挤压棒材或型材a或D≤125 mm》.pdf DS EN 2385-1992 Aerospace series Aluminium alloy AL-P7009-T74511 Extruded bars and sections a or D 125 mm《航空航天系列 铝合金AL-P7009-T74511 挤压棒材或型材a或D≤125 mm》.pdf
  • DS EN 23878-1994 Hardmetals Vickers hardness test《硬质合金 维氏硬度试验》.pdf DS EN 23878-1994 Hardmetals Vickers hardness test《硬质合金 维氏硬度试验》.pdf
  • 相关搜索
    资源标签

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

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