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

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

1、国家二级( C语言)机试模拟试卷 287及答案与解析 一、程序填空题( 30分) 1 函数 fun的功能是:将形参 a所指数组中的前半部分元素中的值和后半部分元素中的值对换。形参 n中存放数组中数据的个数,若 n为奇数,则中问的元素不动。 例如:若 a所指数组中的数据依次为: 1、 2、 3、 4、 5、 6、 7、 8、 9,则调换后为: 6、 7、 8、 9、 5、 1、 2、 3、 4。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKl C中。 不得增行或删行。也不得更改程序的结构 ! #include #define

2、 N 9 void fun(int a, int n) int i, t, p; *found* p=(n 2=0)?n 2: n 2+【 1】; for(i=0; i #include void fun(char*a, char*b, char*c) int i, j; char ch; i=0; j=strlen(b) 1; *found* while(ij) ch=bi; bi=bj; bj=ch; i+; j; while(*a|*b) *found* If(*a) *c=*a; c+; a+; if(*b) *c=*b; c+; b+; *c=0; main() char s1100

3、 s2100, t200; printf(“ nEnter s1 string: “); scanf(“ s“, s1); printf(“ nEnter s2 string: “); scarlf(“ s“, s2); fun(s1, s2, t); printf(“ nThe result is: s n“, t); 三、程序设计题( 40分) 3 请编一个函数 fun,函数的功能是使实型数保留 2位小数,并对第三位进行四舍五入 (规定实型数为正数 )。 例如:实型数为 1234 567,则函数返回 1234 572000; 实型数为 1234 564,则函数返回 1234 562000

4、 注意:部分源程序存在文件 PROGl C文件中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include float fun(float h) main() float a; void NONO(); printf(“Enter a: “); scanf (“ f“, &a); printf(“The original data is: “); printf(“ f nkn“, a); printf(“The result: fn“, fun (a); NONO(); void NONO() *请在此函数内打开文件,输入测试数据,

5、 调用 fun函数,输出数据,关闭文件。 * int i; float a; FILE*rf, *wf; rf=fopen(“in dat“, “r“); wf=fopen(“out dat“, “w“); for(i=0; ii) (2)if(*a) 【试题解析】 (1)检查循环控制表达式 ij,就是当 i大于 j时进入循环,而 i的初值小于 j,所以根本不会进入循环,应将 “while(ij)“改为 “while(ij)“。 (2)第二标识下 “If(*a)“, If没有定义,根据题意,这里是判断 a字符串是否已经到达尾部,应使用 if判断,故第二标识处应改为 “if(*a)“。 三、程序设计题( 40分) 3 【正确答案】 long w; w=h*1000+5; return(float)w 1000; 【试 题解析】 进入 fun函数,根据前面的分析: 本题可以分解为,把一个浮点数截成只带两位小数的算法和将小数点后第三位四舍五入的算法。其中,四舍五入,如果值大于 5那么加上 5就会进位;反之,如果小于 5,加上 5就不会进位,所以在扩大后的值加上 5,实现四舍五入的截取。

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 2184-1998 Aerospace Series Heat Resisting Alloy NI-PH2301 (NiCr21Fe18Mo9) Solution Treated Bar and Section De Less Than or Equal to 200 mm (Edition P 1)《航空航天系列 焊接环用耐热.pdf ASD-STAN PREN 2184-1998 Aerospace Series Heat Resisting Alloy NI-PH2301 (NiCr21Fe18Mo9) Solution Treated Bar and Section De Less Than or Equal to 200 mm (Edition P 1)《航空航天系列 焊接环用耐热.pdf
  • ASD-STAN PREN 2185-1998 Aerospace Series Heat Resisting Alloy NI-PH2301 (NiCr21Fe18Mo9) Solution Treated Sheet Strip and Plate 0 2 mm Less Than or Equal to a Less Than or Equal to .pdf ASD-STAN PREN 2185-1998 Aerospace Series Heat Resisting Alloy NI-PH2301 (NiCr21Fe18Mo9) Solution Treated Sheet Strip and Plate 0 2 mm Less Than or Equal to a Less Than or Equal to .pdf
  • ASD-STAN PREN 2188-1978 Heat Resisting Nickel Base Alloy NI-P95-HT Solution Treated and Precipitation Treated Bar Aerospace Series (Edition 1)《航空航天系列 耐热镍基合金制NI-P95-HT制固溶化处理和沉淀处理的棒材.pdf ASD-STAN PREN 2188-1978 Heat Resisting Nickel Base Alloy NI-P95-HT Solution Treated and Precipitation Treated Bar Aerospace Series (Edition 1)《航空航天系列 耐热镍基合金制NI-P95-HT制固溶化处理和沉淀处理的棒材.pdf
  • ASD-STAN PREN 2193-1980 Heat Resisting Nickel Base Alloy NI-P101-HT Solution Treated and Precipitation Treated Bars Aerospace Series (Edition 1)《航空航天系列 耐热镍基合金制NI-P101-HT制固溶化处理和沉淀处理.pdf ASD-STAN PREN 2193-1980 Heat Resisting Nickel Base Alloy NI-P101-HT Solution Treated and Precipitation Treated Bars Aerospace Series (Edition 1)《航空航天系列 耐热镍基合金制NI-P101-HT制固溶化处理和沉淀处理.pdf
  • ASD-STAN PREN 2195-1979 Heat Resisting Nickel Base Alloy NI-P101-HT Solution Treated and Precipitation Treated Sheet and Strip a Less Than or Equal to 3 mm Aerospace Series (Editio.pdf ASD-STAN PREN 2195-1979 Heat Resisting Nickel Base Alloy NI-P101-HT Solution Treated and Precipitation Treated Sheet and Strip a Less Than or Equal to 3 mm Aerospace Series (Editio.pdf
  • ASD-STAN PREN 2199-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated and Precipitation Treated Bar and Section De Less Than or Equal to 200.pdf ASD-STAN PREN 2199-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated and Precipitation Treated Bar and Section De Less Than or Equal to 200.pdf
  • ASD-STAN PREN 2201-1979 Heat Resisting Nickel Base Alloy NI-P105-HT Solution Treated and Precipitation Treated Bars and Sections for Welded Rings Aerospace Series (Edition 1)《航空航天系.pdf ASD-STAN PREN 2201-1979 Heat Resisting Nickel Base Alloy NI-P105-HT Solution Treated and Precipitation Treated Bars and Sections for Welded Rings Aerospace Series (Edition 1)《航空航天系.pdf
  • ASD-STAN PREN 2202-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated Seamless Tube De Less Than or Equal to 50 mm a Less Than or Equal to 3.pdf ASD-STAN PREN 2202-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated Seamless Tube De Less Than or Equal to 50 mm a Less Than or Equal to 3.pdf
  • ASD-STAN PREN 2203-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated Sheet Strip and Plate 0 2 mm Less Than or Equal to a Less Than or Equa.pdf ASD-STAN PREN 2203-1998 Aerospace Series Heat Resisting Alloy NI-PH1303 (NiCo20Cr20Mo5Ti2AI) Solution Treated Sheet Strip and Plate 0 2 mm Less Than or Equal to a Less Than or Equa.pdf
  • 相关搜索

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

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