【计算机类职业资格】国家二级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 ISO 4656-2012 Rubber compounding ingredients Carbon black Determination of oil absorption number (OAN) and oil absorption number of compressed sample (COAN)《橡胶配合剂 炭黑 油吸收值(OAN)和压.pdf BS ISO 4656-2012 Rubber compounding ingredients Carbon black Determination of oil absorption number (OAN) and oil absorption number of compressed sample (COAN)《橡胶配合剂 炭黑 油吸收值(OAN)和压.pdf
  • BS ISO 4659-2014 Styrene-butadiene rubber (carbon black or carbon black and oil masterbatches) Evaluation procedure《苯乙烯-丁二烯橡胶(炭黑或炭黑和油母炼胶) 评价方法》.pdf BS ISO 4659-2014 Styrene-butadiene rubber (carbon black or carbon black and oil masterbatches) Evaluation procedure《苯乙烯-丁二烯橡胶(炭黑或炭黑和油母炼胶) 评价方法》.pdf
  • BS ISO 4660-2011 Rubber raw natural Colour index test《橡胶 天然生胶 颜色指数试验》.pdf BS ISO 4660-2011 Rubber raw natural Colour index test《橡胶 天然生胶 颜色指数试验》.pdf
  • BS ISO 4662-2017 Rubber vulcanized or thermoplastic Determination of rebound resilience《硫化橡胶和热塑性橡胶 回弹性的测定》.pdf BS ISO 4662-2017 Rubber vulcanized or thermoplastic Determination of rebound resilience《硫化橡胶和热塑性橡胶 回弹性的测定》.pdf
  • BS ISO 4664-1-2011 Rubber vulcanized or thermoplastic Determination of dynamic properties General guidance《硫化或热塑性橡胶 动态性能的测定 通用指南》.pdf BS ISO 4664-1-2011 Rubber vulcanized or thermoplastic Determination of dynamic properties General guidance《硫化或热塑性橡胶 动态性能的测定 通用指南》.pdf
  • BS ISO 4664-2-2006 Rubber vulcanized or thermoplastic - Determination of dynamic properties - Torsion pendulum methods at low frequencies《硫化或热塑性橡胶 动态性能的测定 低频扭摆试验》.pdf BS ISO 4664-2-2006 Rubber vulcanized or thermoplastic - Determination of dynamic properties - Torsion pendulum methods at low frequencies《硫化或热塑性橡胶 动态性能的测定 低频扭摆试验》.pdf
  • BS ISO 4665-2016 Rubber vulcanized or thermoplastic Resistance to weathering《硫化和热塑性橡胶 耐气候性》.pdf BS ISO 4665-2016 Rubber vulcanized or thermoplastic Resistance to weathering《硫化和热塑性橡胶 耐气候性》.pdf
  • BS ISO 4666-1-2010 Rubber vulcanized Determination of temperature rise and resistance to fatigue in flexometer testing Basic principles《硫化橡胶 挠曲计测试中温升和抗疲劳性测定 基本原则》.pdf BS ISO 4666-1-2010 Rubber vulcanized Determination of temperature rise and resistance to fatigue in flexometer testing Basic principles《硫化橡胶 挠曲计测试中温升和抗疲劳性测定 基本原则》.pdf
  • BS ISO 4666-4-2007 Rubber vulcanized - Determination of temperature rise and resistance to fatigue in flexometer testing - Constant-stress flexometer《硫化橡胶 挠曲计测试中温升和抗疲劳性的测定 恒定压力挠曲计》.pdf BS ISO 4666-4-2007 Rubber vulcanized - Determination of temperature rise and resistance to fatigue in flexometer testing - Constant-stress flexometer《硫化橡胶 挠曲计测试中温升和抗疲劳性的测定 恒定压力挠曲计》.pdf
  • 相关搜索

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

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