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

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

1、国家二级( C语言)机试模拟试卷 220及答案与解析 一、程序填空题( 30分) 1 给定程序中,函数 fun的功能是用函数指针指向要调用的函数,并进行调用。规定在【 2】处使 fa指向函数 n,在【 3】处使 fb指向函数 f2。当调用正确时,程序输出: x1=5 000000, x2=3 000000, x1*x1+x1*x2=40 000000 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKI C中。 不得增行或删行, 也不得更改程序的结构 ! #include double f1(double x) return x

2、x; double f2(double x, double y) return x*y; double fun(double a, double b) /*found*/ 【 1】 (*f)(); double r1, r2; /*found*/ f = 【 2】 ; /* point fountion f1 */ r1 = f(a); /*found*/ f = 【 3】 ; /* point fountion f2 */ r2 = (*f)(a, b); return r1 + r2; main() double x1=5, x2=3, r; r = fun(x1, x2); print

3、f(“nx1=%f, x2=%f, x1*x1+x1*x2=%fn“,x1, x2, r); 二、程序修改题( 30分) 2 给 定程序 MODll C中函数 fun的功能是:利用插入排序法对字符串中的字符按从小到大的顺序进行排序。插入法的基本算法是:先对字符串中的头两个元素进行排序。然后把第三个字符插入到前两个字符中,插入后前三个字符依然有序; 再把第四个字符插入到前三个字符中 。待排序的字符串已在主函数中赋予。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 mmn函数,不得增行或删行,也不得更改程序的结构。 #include #include #define N 80 void

4、 insert(char *aa) int i,j,n; char ch; /*found*/ n=strlem(aa); for(i=1; i=0) /* point fountion f1 */ ”和 “r1= f(a);”可知 f是一个函数的指针,且 f指向的函数的返回值为 double型,函数的指针的定义方式是:类型标识符 (*指针变量名 )(),故第一空处的函数的指针的定义为 “double”。 第二空: “f=_2_; /* point fountion f1 */”和 “r1=f(a);”可知 f指向的函数只有一个参数 a,因此 f指向 f1函数,即第二空处为 “f1”。 第三空

5、 “f=_3_; /* point fountion f2 */”和 “r2=(*f)(a,b);”, f指向的函数有两个参数,因此 f是指向 f2函数,故第三空处应为 “f2”。 二、程序修改题( 30分) 2 【正确答案】 n=strlen( aa ); ch=aai; 【试题解析】 ( 1) strlen是求字符串长度的函数,函数调用的形式是: strlen(字符串地址 ),故第一标识下应改成 “n=strlen( aa );”。 ( 2)程序调试时会提示 “c=aai;”中的 c未定义, insert函数中定义的是变量 ch作为存放 aa字符串中字符的临时变量,然后对其与 其他字符进行比较。所以将“c=aai;”改为 “ch=aai;”。 三、程序设计题( 40分) 3 【正确答案】 int j=0; char *p=a; while(*p) if(*p !=*)aj+=*p; p+; aj=0; 【试题解析】 ( 1)首先利用工作指针指向字符串,当指针不指向串尾时,就对字符串进行循环判断。 ( 2)在循环中利用 if判断表达式,判断是字符是否为 “*”,如果不是 “*”将其拷贝到字符串,否则跳过 “*”字符。 ( 3)所有字符处 理完后,记得在新串 s的末尾加上结束符 “0”。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 4377-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Forging Stock a or D Less Than or Equal to 300 mm Edition p 1《航空系列 抗热合金NI-P.pdf AECMA PREN 4377-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Forging Stock a or D Less Than or Equal to 300 mm Edition p 1《航空系列 抗热合金NI-P.pdf
  • AECMA PREN 4378-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Solution Treated and Precipitation Treated Wire for Rivets D Less Than or Equal to 1 6 mm Ed.pdf AECMA PREN 4378-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Solution Treated and Precipitation Treated Wire for Rivets D Less Than or Equal to 1 6 mm Ed.pdf
  • AECMA PREN 4379-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Forging De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(NiCr22Mo9.pdf AECMA PREN 4379-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Forging De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(NiCr22Mo9.pdf
  • AECMA PREN 4380-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Bar and Section De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(N.pdf AECMA PREN 4380-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Bar and Section De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(N.pdf
  • AECMA PREN 4381-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Structural Application D Less Than or Equal to 50 mm a Less T.pdf AECMA PREN 4381-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Structural Application D Less Than or Equal to 50 mm a Less T.pdf
  • AECMA PREN 4382-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Hydraulic Application D Less Than or Equal to 50 mm a Less Th.pdf AECMA PREN 4382-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Hydraulic Application D Less Than or Equal to 50 mm a Less Th.pdf
  • AECMA PREN 4383-1997 Aerospace Series Heat Resisting Alloy NI-CH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔.P1.pdf AECMA PREN 4383-1997 Aerospace Series Heat Resisting Alloy NI-CH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔.P1.pdf
  • AECMA PREN 4384-1997 Aerospace Series Heat Resisting Alloy NI-CH1303 (NiCo20Cr20Mo5Ti2Al) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔..pdf AECMA PREN 4384-1997 Aerospace Series Heat Resisting Alloy NI-CH1303 (NiCo20Cr20Mo5Ti2Al) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔..pdf
  • AECMA PREN 4385-2001 Aerospace Series Non-Metallic Materials General Organisation of Standardisation Links between Types of Standards Edition P 2《航空航天系列.非金属物质一般结构标准类型标准.P2版》.pdf AECMA PREN 4385-2001 Aerospace Series Non-Metallic Materials General Organisation of Standardisation Links between Types of Standards Edition P 2《航空航天系列.非金属物质一般结构标准类型标准.P2版》.pdf
  • 相关搜索

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

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