【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷262及答案解析.doc

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

1、国家二级 C语言机试(操作题)模拟试卷 262及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.函数 fun的功能是:输出 a所指数组中的前 11个数据,要求每行输出 5个数。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1C 中。不得增行或删行,也不得更改程序的结构! 试题程序: #includestdioh #includestdlibh void fun(int*a,int n) int i ; for(i=0;in;i+) *found* if( 【1】 =0) *fo

2、und* printf(“ 【2】 “); *found* printf(“d“, 【3】 ); main() int a100=0,i,n; n=22; for(i=0;in;i+) ai=rand()21; fun(a,n); printf(“n“); (分数:2.00)_二、程序修改题(总题数:1,分数:2.00)2.下列给定程序中,函数 fun的功能是:按以下递归公式求函数的值。 (分数:2.00)_三、程序设计题(总题数:1,分数:2.00)3.请编个函数 flat fun(double h),该函数的功能是:使变量 h中的值保留两位小数,并对第三位进行四舍五入(规定 h中的值为正数

3、)。例如,若 h值为 1234567,则函数返回 1234570000;若 h值为1234564,则函数返回 1234560000。注意:部分源程序在文件 PROG1C 中。请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。试题程序:1 #includestdioh2 #includeconioh3 #includestdlibh4 float fun(float h)5 67 8 void main()9 10 FILE*wf;11 float a;12 system(“CLS“);13 printf(“Enter a:“);14 scanf(“

4、f“, *单精度数 h乘以1000后再加 5,相当于对 h中的第三位小数进行四舍五入,除以 10后将其赋给一个长整型数时就把第三位小数后的数全部截去* return(float)tmp1000; *除以 100,保留 2位小数* )解析:解析:注意:本题要求对 h的值真正进行四舍五人运算,而不是为了输出,即不能用prinff(“72f“,h)来直接得到结果。四舍五入算法:如果要求精确到小数点后面的第 n位,则需要对第 n+1位进行运算。方法是将该小数乘以 10的 n+1次方后加 5,然后除以 10并强制转换变量类型为整型,再将该数除以 10的 n次方,同时强制转换类型为浮点型。 代码实现如下: int t;*定义整型变量t* t=(int)(h*10 n+1 +5)10;*对 h进行操作,得到值浮点型,t 取值时取整数部分。10 n+1 为要扩大的倍数* h=(noat)t10 n ;*将 t缩小 10 n 倍,并转换成浮点型*

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 10695-2000 Water quality Determination of selected organic nitrogen and phosphorus compounds Gas chromatographic methods《水质 所选用的有机氮和磷化合物含量的测定 气相色谱法》.pdf BS EN ISO 10695-2000 Water quality Determination of selected organic nitrogen and phosphorus compounds Gas chromatographic methods《水质 所选用的有机氮和磷化合物含量的测定 气相色谱法》.pdf
  • BS EN ISO 10700-1995 Steel and iron - Determination of manganese content - Flame atomic absorption spectrometric method《钢和铁 锰含量的测定 火焰原子吸收光谱分析法》.pdf BS EN ISO 10700-1995 Steel and iron - Determination of manganese content - Flame atomic absorption spectrometric method《钢和铁 锰含量的测定 火焰原子吸收光谱分析法》.pdf
  • BS EN ISO 10703-2015 Water quality Determination of the activity concentration of radionuclides Method by high resolution gamma-ray spectrometry《水质 放射性核素活性浓度的测定 采用高分辨率γ射线能谱的方法》.pdf BS EN ISO 10703-2015 Water quality Determination of the activity concentration of radionuclides Method by high resolution gamma-ray spectrometry《水质 放射性核素活性浓度的测定 采用高分辨率γ射线能谱的方法》.pdf
  • BS EN ISO 10705-1-1996 Water quality - Detection and enumeration of bacteriophages - Enumeration of F-specific RNA bacteriophages《水质 噬菌体测定和计数 特异性F-RNA噬菌体计数》.pdf BS EN ISO 10705-1-1996 Water quality - Detection and enumeration of bacteriophages - Enumeration of F-specific RNA bacteriophages《水质 噬菌体测定和计数 特异性F-RNA噬菌体计数》.pdf
  • BS EN ISO 10707-1995 Water quality - Evaluation in an aqueous medium of the -ultimate- aerobic biodegradability of organic compounds - Method by analysis of biochemical oxygen dema.pdf BS EN ISO 10707-1995 Water quality - Evaluation in an aqueous medium of the -ultimate- aerobic biodegradability of organic compounds - Method by analysis of biochemical oxygen dema.pdf
  • BS EN ISO 10710-2013 Water quality Growth inhibition test with the marine and brackish water macroalga Ceramium tenuicorne《水质 海洋和微咸水大型海藻红藻(macroalga Ceramium tenuicorne)的成长抑制试验》.pdf BS EN ISO 10710-2013 Water quality Growth inhibition test with the marine and brackish water macroalga Ceramium tenuicorne《水质 海洋和微咸水大型海藻红藻(macroalga Ceramium tenuicorne)的成长抑制试验》.pdf
  • BS EN ISO 10712-1996 Water quality Pseudomonas putida growth inhibition test (Pseudomonas cell multiplication inhibition test)《水质 假单胞杆菌类生长抑制试验(假单胞菌属细胞增殖抑制试验)》.pdf BS EN ISO 10712-1996 Water quality Pseudomonas putida growth inhibition test (Pseudomonas cell multiplication inhibition test)《水质 假单胞杆菌类生长抑制试验(假单胞菌属细胞增殖抑制试验)》.pdf
  • BS EN ISO 10714-2002 Steel and iron - Determination of phosphorus content - Phosphovanadomolybdate spectrophotometric method《钢和铁 磷含量的测定 磷钒钼酸盐分光光度法》.pdf BS EN ISO 10714-2002 Steel and iron - Determination of phosphorus content - Phosphovanadomolybdate spectrophotometric method《钢和铁 磷含量的测定 磷钒钼酸盐分光光度法》.pdf
  • BS EN ISO 10717-2010 Footwear Test method for slide fasteners Burst strength《鞋类 拉链试验方法 崩裂强度》.pdf BS EN ISO 10717-2010 Footwear Test method for slide fasteners Burst strength《鞋类 拉链试验方法 崩裂强度》.pdf
  • 相关搜索

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

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