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

展开阅读全文
相关资源
猜你喜欢
  • ONORM S 5222-1-2000 Sealed radioactive sources-Requirements and classification type testing《密封放射源 要求和分类,》.pdf ONORM S 5222-1-2000 Sealed radioactive sources-Requirements and classification type testing《密封放射源 要求和分类,》.pdf
  • ONORM S 5222-2-2000 Sealed radioactive sources-Leakage test methods for periodical inspections《密封放射源 定期检查用的泄漏试验方法》.pdf ONORM S 5222-2-2000 Sealed radioactive sources-Leakage test methods for periodical inspections《密封放射源 定期检查用的泄漏试验方法》.pdf
  • ONORM S 5222-3-2000 Sealed radioactive sources-Maximum permissible time intervals for periodical inspections《密封放射源 用于定期检查的最大容许时间间隔》.pdf ONORM S 5222-3-2000 Sealed radioactive sources-Maximum permissible time intervals for periodical inspections《密封放射源 用于定期检查的最大容许时间间隔》.pdf
  • ONORM S 5222-4-2000 Sealed radioactive sources-Requirements for sources containing radionuclides in gaseous form《密封放射源 包含气体形态放射性核素的信号源要求》.pdf ONORM S 5222-4-2000 Sealed radioactive sources-Requirements for sources containing radionuclides in gaseous form《密封放射源 包含气体形态放射性核素的信号源要求》.pdf
  • ONORM S 5224-1997 Installations for nuclear medicine - Rules for construction and equipment《防辐射容器 防辐射工作台,防辐射箱,用于核能医疗企业要求和分类》.pdf ONORM S 5224-1997 Installations for nuclear medicine - Rules for construction and equipment《防辐射容器 防辐射工作台,防辐射箱,用于核能医疗企业要求和分类》.pdf
  • ONORM S 5225-1994 Radiation protection Containers tables and safes for use in nuclear medicine - Requirements and Classification - Marking of conformity《用于核医疗学的辐射防护容器,桌子和保险柜 要求和分类 .pdf ONORM S 5225-1994 Radiation protection Containers tables and safes for use in nuclear medicine - Requirements and Classification - Marking of conformity《用于核医疗学的辐射防护容器,桌子和保险柜 要求和分类 .pdf
  • ONORM S 5226-1998 Radiation protection tests for installations for nuclear medicine - Rules for testing the radiation protection for handling with unsealed radioactive material《用于核.pdf ONORM S 5226-1998 Radiation protection tests for installations for nuclear medicine - Rules for testing the radiation protection for handling with unsealed radioactive material《用于核.pdf
  • ONORM S 5230-1997 Radiation protection dosimeters - General rules《辐射防护剂量计 一般规则》.pdf ONORM S 5230-1997 Radiation protection dosimeters - General rules《辐射防护剂量计 一般规则》.pdf
  • ONORM S 5231-1993 Radiation protection dosemeters - Individual dosemeters and portable area monitors with ionization Chambers countertubes or scintillators for y- and X-rays - Mark.pdf ONORM S 5231-1993 Radiation protection dosemeters - Individual dosemeters and portable area monitors with ionization Chambers countertubes or scintillators for y- and X-rays - Mark.pdf
  • 相关搜索
    资源标签

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

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