【计算机类职业资格】计算机二级(C)上机考试30及答案解析.doc

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

1、计算机二级(C)上机考试 30及答案解析(总分:-3.00,做题时间:120 分钟)1.填空题 请补充 main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。 例如:当 strN=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #include #define N 80 void main() int

2、 j; char strN=“ 123abcdef ABCDEF!“; char *pf=str; clrscr(); printf(“*original string */n“); puts(str); 【1】; while(*(pf+j) if(*(pf+j)=a for(j=2; j=a for(j=2; j=high/2; j+) /*found*/ ifhigh%j=0 yes=0; break; /*found*/ if(yes=0) sum+=high; n+; high-; return sum; main() clrscr(); printf(“%d/n“,fun(100);

3、 (分数:-1.00)_正确答案:((1)错误:ifhigh%j=0 正确:if(high%j=0) (2)错误:if(yes=0) 正确:if(yes) )解析:错误 1:if 语句的两侧要加括号。 错误 2:yes 为 1时,说明被判断的数为素数,要加入总和。 3.编程题 请编写函数 fun,其功能是:将两个两位数的正整数 a、b 合并形成一个整数放在 c中。合并的方式是:将 a数的十位和个位数依次放在 c数个位和十位上,b 数的十位和个位数依次放在 c数的百位和千位上。 例如,当 a=16,b=35,调用该函数后,c=5361。 注意:部分源程序给出如下。 请勿改动主函数 main和其他

4、函数中的任何内容,仅在函数 fun的花括号中填入所编写的若干语句。 试题程序: #include void fun(int a ,int b,long *c) main() int a,b; long c; clrscr(); printf(“Input a,b;“); scanf(“%d%d“, fun(a,b, printf(“The result is:%ld/n“,c); (分数:-1.00)_正确答案:(void fun(int a ,int b,long *c) *c=(b%10)*1000+(b/10)*100+(a%10)*10+a/10; )解析:语句*c=(b%10)*1000+(b/10)*100+(a%10)*10+a/10;是将 a数的十位和个位数依次放在 c数个位和十位上,b 数的十位和个位数依次放在 c数的百位和千位上。注意“/“和“%“的用法。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2862-1993 Aerospace Series Nuts Anchor Self-Locking Fixed 90 Degree Corner with Counterbore in Alloy Steel Cadmium Plated MoS2 Lubricated Classification  1 100 MPa (at A.pdf AECMA PREN 2862-1993 Aerospace Series Nuts Anchor Self-Locking Fixed 90 Degree Corner with Counterbore in Alloy Steel Cadmium Plated MoS2 Lubricated Classification 1 100 MPa (at A.pdf
  • AECMA PREN 2863-1993 Aerospace Series Nuts Anchor Self-Locking Fixed 90 Degree Corner with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification  1 100 MPa (at Ambient.pdf AECMA PREN 2863-1993 Aerospace Series Nuts Anchor Self-Locking Fixed 90 Degree Corner with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification 1 100 MPa (at Ambient.pdf
  • AECMA PREN 2865-1993 Aerospace Series Nuts Anchor Self-Locking Floating Two Lug with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification  1 100 MPa (at Ambient Tempe.pdf AECMA PREN 2865-1993 Aerospace Series Nuts Anchor Self-Locking Floating Two Lug with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification 1 100 MPa (at Ambient Tempe.pdf
  • AECMA PREN 2866-1992 Aerospace Series Nuts Anchor Self-Locking Floating One Lug with Counterbore in Steel Cadmium Plated MoS2 Lubricated Classification  1 110 MPa (at Ambient Tempe.pdf AECMA PREN 2866-1992 Aerospace Series Nuts Anchor Self-Locking Floating One Lug with Counterbore in Steel Cadmium Plated MoS2 Lubricated Classification 1 110 MPa (at Ambient Tempe.pdf
  • AECMA PREN 2867-1992 Aerospace Series Nuts Anchor Self-Locking Floating One Lug with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification  1 110 MPa (at Ambient Tempe.pdf AECMA PREN 2867-1992 Aerospace Series Nuts Anchor Self-Locking Floating One Lug with Counterbore in Heat Resisting Steel MoS2 Lubricated Classification 1 110 MPa (at Ambient Tempe.pdf
  • AECMA PREN 2868-1993 Aerospace Series Nuts Hexagonal Slotted Castellated Normal Height Normal Across Flats in Heat Resisting Steel Silver Plated Classification  1 100 MPa (at Ambie.pdf AECMA PREN 2868-1993 Aerospace Series Nuts Hexagonal Slotted Castellated Normal Height Normal Across Flats in Heat Resisting Steel Silver Plated Classification 1 100 MPa (at Ambie.pdf
  • AECMA PREN 2869-1993 Aerospace Series Nuts Hexagonal Slotted Castellated Normal Height Normal Across Flats in Heat Resisting Steel Passivated Classification  1 100 MPa (at Ambient .pdf AECMA PREN 2869-1993 Aerospace Series Nuts Hexagonal Slotted Castellated Normal Height Normal Across Flats in Heat Resisting Steel Passivated Classification 1 100 MPa (at Ambient .pdf
  • AECMA PREN 2870-1990 Aerospace Series Bolts Bihexagonal Normal Head Close Tolerance Normal Shank Short Thread in Titanium Alloy Anodized MoS2 Lubricated Classification 1100 MPa (at.pdf AECMA PREN 2870-1990 Aerospace Series Bolts Bihexagonal Normal Head Close Tolerance Normal Shank Short Thread in Titanium Alloy Anodized MoS2 Lubricated Classification 1100 MPa (at.pdf
  • AECMA PREN 2874-1992 Aerospace Series Bolts Large Bihexagonal Head Close Tolerance Normal Shank Medium Length Thread in Nickel Alloy Passivated Classification  1 550 MPa (at Ambien.pdf AECMA PREN 2874-1992 Aerospace Series Bolts Large Bihexagonal Head Close Tolerance Normal Shank Medium Length Thread in Nickel Alloy Passivated Classification 1 550 MPa (at Ambien.pdf
  • 相关搜索
    资源标签

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

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