[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc

上传人:roleaisle130 文档编号:502923 上传时间:2018-11-29 格式:DOC 页数:5 大小:33.50KB
下载 相关 举报
[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc_第1页
第1页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc_第2页
第2页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc_第3页
第3页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc_第4页
第4页 / 共5页
[计算机类试卷]国家二级(C语言)机试模拟试卷181及答案与解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级( C语言)机试模拟试卷 181及答案与解析 一、程序填空题( 30分) 1 给定程序中,函数 fun的功能是:在形参 s所指字符串中寻找与参数 c相同的字符,并在其后插入一个与之相同的字符,若找不到相同的字符则函数不做任何处理。 例如, s所指字符串为: baacda, c中的字符为: a,执行后 s所指字符串为:baaaacdaa。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKI C中。 不得增行或删行,也不 得更改程序的结构 ! #include void fun(char *s, char c) int i

2、 j, n; /*found*/ for(i=0; si!=【 1】 ; i+) if(si=c) /*found*/ n=【 2】 ; while(si+1+n!=0) n+; for(j=i+n+1; ji; j-) sj+1=sj; /*found*/ sj+1=【 3】 ; i=i+1; main() char s80=“baacda“, c; printf(“nThe string: %sn“,s); printf(“nInput a character: “); scanf(“%c“, fun(s,c); printf(“nThe result is: %sn“,s); 二、程序

3、修改题( 30分) 2 给定程序 MODll C中函数 fun的功能是:计算整数 n的阶乘。请改正程序中的错误或在下划线处填上适当的内容并把下划线删除,使它能计算出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构 ! #include double fun(int n) double result=1 0; while(n1 j-)sj+1=sj;”循环结束时 j=i,即 sj+1是 si之后的字符,在此位置插入字符 c,所以第三空是 “c”。 二、程序修改题( 30分) 2 【正确答案】 result *=n-; return result; 【试题解析】 (

4、 1)第一个标识下 while循环过程实现 n的阶乘,根据阶乘的算法 n!=n*(n-1)*1 ,题干中的语句 “result *=-n;”先对 n进行减 1操作,结果就少乘了 n,所以将 “result *=-n;”改为 “result *=n-;”。 ( 2)根据 fun函数的定义, fun函数应该返回阶乘结果,所以第二个标识下填空为 “return result;”。 三、程序设计题( 40分) 3 【正确答案】 int i,j; for(i=0;imm;i+) for(j=0;jnn;j+) b*n=*(*(s+i)+j); *n=*n+1; 【试题解析】 ( 1)利用两重循环,依次取矩阵中的元素。 ( 2)其中注意指针数组与数组指针的区别,其中数组指针 s,它指向包含 4个元素的一维数组。其数据元素的表示方式为: “*(*(s+i)+j)”。

展开阅读全文
相关资源
猜你喜欢
  • STAS 7335 2-1988 Corrosion protection of burried metallic constructions CONVENTIONAL SIGNS《埋地金属结构的腐蚀防护 常规标记 》.pdf STAS 7335 2-1988 Corrosion protection of burried metallic constructions CONVENTIONAL SIGNS《埋地金属结构的腐蚀防护 常规标记 》.pdf
  • STAS 7335 3-1986 Corrosion pretection of buried meta- lic structures EXTERNAL COATING WITH BITU- MEN OF STEEL PIPELINES《埋地金属结构腐蚀防护 钢制管道沥青外表涂料 》.pdf STAS 7335 3-1986 Corrosion pretection of buried meta- lic structures EXTERNAL COATING WITH BITU- MEN OF STEEL PIPELINES《埋地金属结构腐蚀防护 钢制管道沥青外表涂料 》.pdf
  • STAS 7335 4-1977 Non-corrosive protcction BURIED METALIC STRUCTURES Cu CuS04 comparation electrode《不腐蚀 埋入式金属结构Cu CuS04 标准电极 》.pdf STAS 7335 4-1977 Non-corrosive protcction BURIED METALIC STRUCTURES Cu CuS04 comparation electrode《不腐蚀 埋入式金属结构Cu CuS04 标准电极 》.pdf
  • STAS 7335 5-1990 Protection against corrosion of burried metallic structures Electroinsulating joints with nipple《地下金属结构体的腐蚀防护 带接头的绝缘螺纹接管 》.pdf STAS 7335 5-1990 Protection against corrosion of burried metallic structures Electroinsulating joints with nipple《地下金属结构体的腐蚀防护 带接头的绝缘螺纹接管 》.pdf
  • STAS 7335 6-1980 Corrosion protection of burried metal constructions PROTECTION OF PIPES AT WATER UNDERCOSSINGS AND AT PASSES THROUGH MANHOLES《埋地金属结构腐蚀防护 人孔和水下管道保护 》.pdf STAS 7335 6-1980 Corrosion protection of burried metal constructions PROTECTION OF PIPES AT WATER UNDERCOSSINGS AND AT PASSES THROUGH MANHOLES《埋地金属结构腐蚀防护 人孔和水下管道保护 》.pdf
  • STAS 7335 7-1987 Corrosion protection of underground metal structures ELECTRICAL INSULATING FLAN- GED JOI NT S《地下金属结构的腐蚀防护 绝缘法兰接头 》.pdf STAS 7335 7-1987 Corrosion protection of underground metal structures ELECTRICAL INSULATING FLAN- GED JOI NT S《地下金属结构的腐蚀防护 绝缘法兰接头 》.pdf
  • STAS 7335 8-1985 Corrosion protection of burried metal construction TEST STATIONS FOR POTENTIAL《埋入式金属结构的防腐蚀 电势的试验站 》.pdf STAS 7335 8-1985 Corrosion protection of burried metal construction TEST STATIONS FOR POTENTIAL《埋入式金属结构的防腐蚀 电势的试验站 》.pdf
  • STAS 7335 9-1988 Corrosion protection of underground metallic constructions OUTER CATHODIG PROTECTION AND EARTHING BY METALLIC ACTIVE ANO0ES General specifications《地下金属结构的防腐 金属活性剂外.pdf STAS 7335 9-1988 Corrosion protection of underground metallic constructions OUTER CATHODIG PROTECTION AND EARTHING BY METALLIC ACTIVE ANO0ES General specifications《地下金属结构的防腐 金属活性剂外.pdf
  • STAS 7338-1982 STRAIGHT-SIDED INVOLUTE SPLINES Limits and fits《内卷矩形花键 极限与配合 》.pdf STAS 7338-1982 STRAIGHT-SIDED INVOLUTE SPLINES Limits and fits《内卷矩形花键 极限与配合 》.pdf
  • 相关搜索

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

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