【计算机类职业资格】计算机二级(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解析:本题旨在考查控制数组中右上半三角元素的算法,也就是两个千篇一律的循环语句,希望学习者能够掌握消化。

展开阅读全文
相关资源
猜你喜欢
  • EN 13583-2012 en Flexible sheets for waterproofing - Bitumen plastic and rubber sheets for roof waterproofing - Determination of hail resistance《防水软板 屋顶防水沥青 塑料和橡胶片 冰雹耐受性测定》.pdf EN 13583-2012 en Flexible sheets for waterproofing - Bitumen plastic and rubber sheets for roof waterproofing - Determination of hail resistance《防水软板 屋顶防水沥青 塑料和橡胶片 冰雹耐受性测定》.pdf
  • EN 13584-2003 en Products and systems for the protection and repair of concrete structures - Test methods - Determination of creep in compression for repair products《混凝土结构保护和修缮用产品及.pdf EN 13584-2003 en Products and systems for the protection and repair of concrete structures - Test methods - Determination of creep in compression for repair products《混凝土结构保护和修缮用产品及.pdf
  • EN 13585-2001 en Foodstuffs - Determination of Fumonisins B1 and B2 in Maize - HPLC Method with Solid Phase Extraction Clean-Up《食品 玉米中Fumonisins B1和B2的测定 固相萃取提纯的HPLC方法》.pdf EN 13585-2001 en Foodstuffs - Determination of Fumonisins B1 and B2 in Maize - HPLC Method with Solid Phase Extraction Clean-Up《食品 玉米中Fumonisins B1和B2的测定 固相萃取提纯的HPLC方法》.pdf
  • EN 13586-2004 en Cranes - Access (Incorporates Amendment A1 2008)《起重机 检修孔 包含修改件A1-2008》.pdf EN 13586-2004 en Cranes - Access (Incorporates Amendment A1 2008)《起重机 检修孔 包含修改件A1-2008》.pdf
  • EN 13588-2017 en Bitumen and bituminous binders - Determination of cohesion of bituminous binders with pendulum test.pdf EN 13588-2017 en Bitumen and bituminous binders - Determination of cohesion of bituminous binders with pendulum test.pdf
  • EN 1359-1998 Gas Meters - Diaphragm Gas Meters (Incorporates Amendment A1 2006)《燃气表 隔膜燃气表 包含修改件A1-2006》.pdf EN 1359-1998 Gas Meters - Diaphragm Gas Meters (Incorporates Amendment A1 2006)《燃气表 隔膜燃气表 包含修改件A1-2006》.pdf
  • EN 1359-2017 en Gas meters - Diaphragm gas meters.pdf EN 1359-2017 en Gas meters - Diaphragm gas meters.pdf
  • EN 13590-2003 en Packaging - Flexible carrier bags for the transport of various retail goods - General characteristics and test methods for the determination of volume and carrying.pdf EN 13590-2003 en Packaging - Flexible carrier bags for the transport of various retail goods - General characteristics and test methods for the determination of volume and carrying.pdf
  • EN 13591-2005 en Food processing machinery - Fixed deck oven loaders - Safety and hygiene requirements (Incorporates Amendment A1 2009)《食品加工机械 固定台式炉装料机 安全和卫生要求 包含修改件A1-2009》.pdf EN 13591-2005 en Food processing machinery - Fixed deck oven loaders - Safety and hygiene requirements (Incorporates Amendment A1 2009)《食品加工机械 固定台式炉装料机 安全和卫生要求 包含修改件A1-2009》.pdf
  • 相关搜索
    资源标签

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

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