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

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

1、二级 C 语言-60 及答案解析(总分:71.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:1.00)1.请补充函数 fun(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a 指向原字符串,删除后的字符串存放在 b 所指的数组中,c 中存放指定的字符。 例如:当a 输入“abababa”,ca时,b 的输出为“ababb”; 如果 a 的输入为“ababa”,则 b 的输出为“ababa”。 注意:部分源程序给出如下。 请勿改动主函数 main

2、 和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdioh #includeconioh #define LEN 80 void fun(char a,char b,char C) int i=0,j=0; int n=0; int m=0; while(ai!=/0) if(ai=c) n+; i+; U U /U /U;if(n%2) while(aj!=/0) bj=aj; j+; bj=/0; else while(ai!=/0) bj+=ai; if(ai=c) m+; if(mn/2)clrscr();printf(

3、Enter s1 and s2:/n“);scanf(“%s%s“, s1, s2);printf(“s1=%s/n“, s1);printf(“s2=%s/n“, s2);printf(“Invoke fun(s1, s2):/n“);fun(s1, s2);printf(“After invoking:/n“);printf(“%s/n“, s1);(分数:40.00)_二级 C 语言-60 答案解析(总分:71.00,做题时间:90 分钟)一、B填空题/B(总题数:1,分数:1.00)1.请补充函数 fun(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该

4、字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a 指向原字符串,删除后的字符串存放在 b 所指的数组中,c 中存放指定的字符。 例如:当a 输入“abababa”,ca时,b 的输出为“ababb”; 如果 a 的输入为“ababa”,则 b 的输出为“ababa”。 注意:部分源程序给出如下。 请勿改动主函数 main 和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdioh #includeconioh #define LEN 80 void fun(char a,ch

5、ar b,char C) int i=0,j=0; int n=0; int m=0; while(ai!=/0) if(ai=c) n+; i+; U U /U /U;if(n%2) while(aj!=/0) bj=aj; j+; bj=/0; else while(ai!=/0) bj+=ai; if(ai=c) m+; if(mn/2)clrscr();printf(“Enter s1 and s2:/n“);scanf(“%s%s“, s1, s2);printf(“s1=%s/n“, s1);printf(“s2=%s/n“, s2);printf(“Invoke fun(s1, s2):/n“);fun(s1, s2);printf(“After invoking:/n“);printf(“%s/n“, s1);(分数:40.00)_正确答案:(void fun(char p1, char p2) int i=0, n=0; char *p=p1, *q=p2; while(*p) p+; n+; i=n; while(*q) p1i=*q; q+; i+; p1i=/0; )解析:解析 用指针遍历第一个字符串,把指针定位到串尾标志符处;遍历第二个字符串,依次把字符复制到第一个字符串的末尾;最后赋结尾标志符。

展开阅读全文
相关资源
猜你喜欢
  • EN 60717-2012 en Method for the determination of the space required by capacitors and resistors with unidirectional terminations.pdf EN 60717-2012 en Method for the determination of the space required by capacitors and resistors with unidirectional terminations.pdf
  • EN 60719-1993 en Calculation of the Lower and Upper Limits for the Average Outer Dimensions of Cables with Circular Copper Conductors and of Rated Voltages up to and Including 450 .pdf EN 60719-1993 en Calculation of the Lower and Upper Limits for the Average Outer Dimensions of Cables with Circular Copper Conductors and of Rated Voltages up to and Including 450 .pdf
  • EN 60721-1-1995 en Classification of Environmental Conditions Part 1 Environmental Parameters and Their Severities (Incorporates A2)《环境条件分类 第1部分 环境参数极其严格性(包含A2)(IEC 721-1-1990+A1-1.pdf EN 60721-1-1995 en Classification of Environmental Conditions Part 1 Environmental Parameters and Their Severities (Incorporates A2)《环境条件分类 第1部分 环境参数极其严格性(包含A2)(IEC 721-1-1990+A1-1.pdf
  • EN 60721-2-1-2014 en Classification of environmental conditions - Part 2-1 Environmental conditions appearing in nature - Temperature and Humidity.pdf EN 60721-2-1-2014 en Classification of environmental conditions - Part 2-1 Environmental conditions appearing in nature - Temperature and Humidity.pdf
  • EN 60721-2-2-2013 en Classification of environmental conditions - Part 2-2 Environmental conditions appearing in nature - Precipitation and wind.pdf EN 60721-2-2-2013 en Classification of environmental conditions - Part 2-2 Environmental conditions appearing in nature - Precipitation and wind.pdf
  • EN 60721-2-3-2014 en Classification of environmental conditions - Part 2-3 Environmental conditions appearing in nature - Air pressure.pdf EN 60721-2-3-2014 en Classification of environmental conditions - Part 2-3 Environmental conditions appearing in nature - Air pressure.pdf
  • EN 60721-2-9-2014 en Classification of environmental conditions - Part 2-9 Environmental conditions appearing in nature - Measured shock and vibration data - Storage transportation.pdf EN 60721-2-9-2014 en Classification of environmental conditions - Part 2-9 Environmental conditions appearing in nature - Measured shock and vibration data - Storage transportation.pdf
  • EN 60721-3-0-1993 en Classification of Environmental Conditions Part 3 Classification of Groups of Environmental Parameters and Their Severities Introduction《环境条件分类 第3部分 环境参数组及其严酷程.pdf EN 60721-3-0-1993 en Classification of Environmental Conditions Part 3 Classification of Groups of Environmental Parameters and Their Severities Introduction《环境条件分类 第3部分 环境参数组及其严酷程.pdf
  • EN 60721-3-1-1997 en fr Classification of Environmental Conditions Part 3 Classification of Groups of Environmental Parameters and Their Severities Section 1 Storage (Remains Curre.pdf EN 60721-3-1-1997 en fr Classification of Environmental Conditions Part 3 Classification of Groups of Environmental Parameters and Their Severities Section 1 Storage (Remains Curre.pdf
  • 相关搜索

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

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