【计算机类职业资格】二级C语言-55及答案解析.doc

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

1、二级 C语言-55 及答案解析(总分:100.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:30.00)1.请补充函数 fun(),该函数的功能是:从键盘输入一个下标 n,把数组 aa中比元素 aan小的元素放在它的左边,比它大的元素放在它的右边,排列成的新数组仍然保存在原数组中。 例如,数组aa=33,67,42,58,25,76,85,16,41, 56,输入 3。 结果输出“33,42,25,16,41,56,58,67,76,85”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仪在函数 fun()的横线上填入所编写的若干表达式或语句。

2、 试题程序: #includestdio.h #define N 10 void fun(int aa,int n) int i,j=0,k=0,t; int bbN;t=aan; for(i=0;iN;i+) if(aait) bbj+=aai; if(aait) aak+=aai; U U /U /U; for(i=0;U U /U /U;i+, k+) aak=bbi; main() int i,n; int aaN=33,67,42,58,25,76,85,16,41,56; clrscr(); printf(“/n* original list */n“); for(i=0;iN;i

3、+) printf(“%4d“/aai); printf(“/n suffix n/n“); scanf(“%d“, i+) printf(“%4d“, aai); (分数:30.00)填空项 1:_二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中函数 fun的功能是:把从主函数中输入的 3个数,最大的数放在 a中,中间的数放在 b中,最小的数放在 C中。 例如,若输入的数为:55 12 34,输出的结果应当是a=55.0,b=34.0,c=12.0。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构! 试题程序:

4、 #includestdio.h void fun(float*a,float*b,float*c) /*found*/ float*k; if(*a*b) k=*a: *a=*b: *b=k; /*found*/ if(*a*c) k=*c: *c=*a: *a=k; if(*b*c) k=*b; *b=*c; *c=k; void main() float a,b,c; printf(“Input a b c:“); scanf(“%f%f%f“, system (“CLS“); printf (“ / nPlease enter string: “); gets (a); printf

5、(“/nPlease enter a char:“); ch=getehar (); printf (“/nThe number of the char is:% d/n“, fun(a, ch); (分数:40.00)_二级 C语言-55 答案解析(总分:100.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:30.00)1.请补充函数 fun(),该函数的功能是:从键盘输入一个下标 n,把数组 aa中比元素 aan小的元素放在它的左边,比它大的元素放在它的右边,排列成的新数组仍然保存在原数组中。 例如,数组aa=33,67,42,58,25,76,85,16,41, 56,

6、输入 3。 结果输出“33,42,25,16,41,56,58,67,76,85”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仪在函数 fun()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdio.h #define N 10 void fun(int aa,int n) int i,j=0,k=0,t; int bbN;t=aan; for(i=0;iN;i+) if(aait) bbj+=aai; if(aait) aak+=aai; U U /U /U; for(i=0;U U /U /U;i+, k+) aak=bbi;

7、main() int i,n; int aaN=33,67,42,58,25,76,85,16,41,56; clrscr(); printf(“/n* original list */n“); for(i=0;iN;i+) printf(“%4d“/aai); printf(“/n suffix n/n“); scanf(“%d“, i+) printf(“%4d“, aai); (分数:30.00)填空项 1:_ (正确答案:1 aak+=t 2ij)解析:解析 填空 1:首先将 aan赋值给 t,通过 for循环,将比 t大的数暂存在数组 bb中,将比 t小的数保存在数组 aa中,此时应

8、该将 t存入数组 aa中,正好放在那些小于 t的元素后面。填空 2:最后将数组 bb中的元素存入数组 aa中,放在 t的后面。变量 j记录了大于 t的元素的个数,所以变量 i的取值范围是从 0到 j-1。二、B改错题/B(总题数:1,分数:30.00)2.下列给定程序中函数 fun的功能是:把从主函数中输入的 3个数,最大的数放在 a中,中间的数放在 b中,最小的数放在 C中。 例如,若输入的数为:55 12 34,输出的结果应当是a=55.0,b=34.0,c=12.0。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构! 试题程

9、序: #includestdio.h void fun(float*a,float*b,float*c) /*found*/ float*k; if(*a*b) k=*a: *a=*b: *b=k; /*found*/ if(*a*c) k=*c: *c=*a: *a=k; if(*b*c) k=*b; *b=*c; *c=k; void main() float a,b,c; printf(“Input a b c:“); scanf(“%f%f%f“, system (“CLS“); printf (“ / nPlease enter string: “); gets (a); print

10、f (“/nPlease enter a char:“); ch=getehar (); printf (“/nThe number of the char is:% d/n“, fun(a, ch); (分数:40.00)_正确答案:(int fun(char *ss, char c)int i=0;for(;*ss!=/0;ss+)if(*ss=c) i+;/*求出 ss所指字符串中指定字符的个数*/return i;答案考生文件夹)解析:解析 本题考查:for 循环语句遍历字符串,并通过 if条件语句,判断字符串是否结束。 解题思路 从字符串中查找指定字符,需要使用循环判断结构,循环语句用来遍历字符串,循环条件为字符串没有结束,即当前字符不是/0,判断语句用来判断当前字符是否为指定字符。最后返回指定字符的个数。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索
    资源标签

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

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