【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷301及答案解析.doc

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

1、国家二级 C语言机试(操作题)模拟试卷 301及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.下列给定程序中,函数 fun的功能是计算下式 直到 (分数:2.00)_二、程序修改题(总题数:1,分数:2.00)2.下列给定程序中,函数 fun的功能是:用下面的公式求 的近似值,直到最后一项的绝对值小于指定的数(参数 num)为止。 (分数:2.00)_三、程序设计题(总题数:1,分数:2.00)3.编写函数 fun,其功能是:将 ss所指字符串中所有下标为奇数位上的字母转换为大写(若该位置上不是字母,则不转换)。例如,若输入“abc4EFg”,

2、则应输出“aBc4EFg”。注意:部分源程序给出如下。请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。试题程序:#includeconioh#includestdioh#includestringhvoid fun(char*ss)void main(void) char tt51; printf(“nPlease enter an character string within 50 characters:n“); gets(tt); printf(“nnAfter changing,the stringns“,tt); fun(tt);pri

3、ntf(“nbecomesns“,tt);(分数:2.00)_国家二级 C语言机试(操作题)模拟试卷 301答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.下列给定程序中,函数 fun的功能是计算下式 直到 (分数:2.00)_正确答案:(正确答案:(1)0 (2)i+或+i 或 i+=1或 i=i+1 (3)20*i)解析:解析:填空 1:循环变量 i从 1开始参加运算,但是在每次循环的开始 i都进行自加 1操作,故 i应赋初值为 0。 填空 2:循环变量 i自增 1运算。 填空 3:根据公式确定表达式通项。注意 x为 double型,故应将

4、i变为 double型再进行运算。二、程序修改题(总题数:1,分数:2.00)2.下列给定程序中,函数 fun的功能是:用下面的公式求 的近似值,直到最后一项的绝对值小于指定的数(参数 num)为止。 (分数:2.00)_正确答案:(正确答案:(1)while(fabs(t)=num) (2)t=sn;)解析:解析:(1)函数 fun中 while语句的作用是,当新的一项大于给定参数时,循环累计计算 s的值。题目要求最后一项的绝对值小于给定参数,因此循环条件应当是 while(fabs(t)=num)。 (2)变量 t用来存放最后一项的值,因为每一项均为 1或一 1除以一个数,所以此处应使用除

5、法运算符“”。三、程序设计题(总题数:1,分数:2.00)3.编写函数 fun,其功能是:将 ss所指字符串中所有下标为奇数位上的字母转换为大写(若该位置上不是字母,则不转换)。例如,若输入“abc4EFg”,则应输出“aBc4EFg”。注意:部分源程序给出如下。请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。试题程序:#includeconioh#includestdioh#includestringhvoid fun(char*ss)void main(void) char tt51; printf(“nPlease enter an cha

6、racter string within 50 characters:n“); gets(tt); printf(“nnAfter changing,the stringns“,tt); fun(tt);printf(“nbecomesns“,tt);(分数:2.00)_正确答案:(正确答案:void tun(cnar*ss) int i; for(i=0;ssi!=0;i+) *将 ss所指字符串中所有下标为奇数位置的字母转换为大写* if(i2=1ssi=assi=z) ssi=ssi一 32; )解析:解析:将指定字符串中奇数位置的字母转换为大写,首先需要判断奇数位置,再判断该位置字符是不是小写字母,如果是小写字母,则将小写字母转换为大写字母。字母大小写转换操作中,只要将小写字母减去 32即可转换为大写字母。

展开阅读全文
相关资源
猜你喜欢
  • SIS SS-EN 145-1990 Respiratory protective devices  Self- contained closed-circuit breathing apparatus compressed oxygen type  Requirements testing marking《呼吸防护装置 自载闭路电视呼吸器,压缩氧气类型 要.pdf SIS SS-EN 145-1990 Respiratory protective devices Self- contained closed-circuit breathing apparatus compressed oxygen type Requirements testing marking《呼吸防护装置 自载闭路电视呼吸器,压缩氧气类型 要.pdf
  • SIS SS-EN 146-1991 Respiratory protective devices  Powered particle filtering devices incorporating helmets or hoods  Requirements testing and marking《呼吸防护装置 有源粒子过滤装置或盔罩 要求,试验和标记》.pdf SIS SS-EN 146-1991 Respiratory protective devices Powered particle filtering devices incorporating helmets or hoods Requirements testing and marking《呼吸防护装置 有源粒子过滤装置或盔罩 要求,试验和标记》.pdf
  • SIS SS-EN 147-1991 Respiratory protective devices  Power assisted particle filtering devices incorporating full face masks half masks or quarter masks  Requirements testing and mar.pdf SIS SS-EN 147-1991 Respiratory protective devices Power assisted particle filtering devices incorporating full face masks half masks or quarter masks Requirements testing and mar.pdf
  • SIS SS-EN 148-1-1990 Respiratory protective devices  Threads for facepieces  Standard thread connec- tion《呼吸防护装置 面罩螺纹 标准螺纹连接》.pdf SIS SS-EN 148-1-1990 Respiratory protective devices Threads for facepieces Standard thread connec- tion《呼吸防护装置 面罩螺纹 标准螺纹连接》.pdf
  • SIS SS-EN 148-2-1990 Respiratory protective devices  Threads for facepieces  Centre thread connection《呼吸防护装置 面罩螺纹 中心螺纹连接》.pdf SIS SS-EN 148-2-1990 Respiratory protective devices Threads for facepieces Centre thread connection《呼吸防护装置 面罩螺纹 中心螺纹连接》.pdf
  • SIS SS-EN 148-3-1992 Respiratory protective devices  Threads for facepieces  Thread connection M 45x3《呼吸防护装置 面罩螺纹 螺纹连接M 45x3》.pdf SIS SS-EN 148-3-1992 Respiratory protective devices Threads for facepieces Thread connection M 45x3《呼吸防护装置 面罩螺纹 螺纹连接M 45x3》.pdf
  • SIS SS-EN 149-1991 Respiratory protective devices  Filtering half masks to protect against particles  Requirements testing marking《呼吸防护设备 防止颗粒的过滤半面罩 要求,试验,标记》.pdf SIS SS-EN 149-1991 Respiratory protective devices Filtering half masks to protect against particles Requirements testing marking《呼吸防护设备 防止颗粒的过滤半面罩 要求,试验,标记》.pdf
  • SIS SS-EN 153-1990 Methods of measuring the energy consumption of electric mains operated householding refrigerators frozen food storage cabinets food freezers and their combinatio力家.pdf SIS SS-EN 153-1990 Methods of measuring the energy consumption of electric mains operated householding refrigerators frozen food storage cabinets food freezers and their combinatio力家.pdf
  • SIS SS-EN 159-1991 Dust-pressed ceramic tiles with water absorption E  10 %  Group Bill《低吸水率E  10 %的粉尘压瓷砖Bill组》.pdf SIS SS-EN 159-1991 Dust-pressed ceramic tiles with water absorption E 10 % Group Bill《低吸水率E 10 %的粉尘压瓷砖Bill组》.pdf
  • 相关搜索

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

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