【计算机类职业资格】三级网络技术机试-126及答案解析.doc

上传人:dealItalian200 文档编号:1321859 上传时间:2019-10-17 格式:DOC 页数:4 大小:28.50KB
下载 相关 举报
【计算机类职业资格】三级网络技术机试-126及答案解析.doc_第1页
第1页 / 共4页
【计算机类职业资格】三级网络技术机试-126及答案解析.doc_第2页
第2页 / 共4页
【计算机类职业资格】三级网络技术机试-126及答案解析.doc_第3页
第3页 / 共4页
【计算机类职业资格】三级网络技术机试-126及答案解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级网络技术机试-126 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN42.DAT 中存有 N 个实数(N200),函数 ReadDat()读取这 N 个实数并存入数组 xx 中。请编制程序 Ca1Value(),其功能要求:(1)求出这 N 个实数的平均值 aver。(2)分别求出这 N 个实数的整数部分值之和 sumint 及其小数部分之和 sumdec,最后调用函数 WriteDat()把所求的结果输出到文件 OUT42.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和

2、写函数 WriteDat()的内容。试题程序:#includestdio.h#includeconio.h#define MAXNUM 200float xxMAXNUM;int N=0;double aver=0.0;double sumint=0.0;double sumdec=0.0;int ReadDat( );void WriteDat( );void CalValue( )void main ( )clrscr ( );if (ReadDat ( ) )printf (“数据文件 IN42.DAT 不能打开! /007/n“);return;CalValue ( );printf

3、文件 IN42.DAT 中共有实数%d 个/n“, N);printf (“平均值=%.21f/n“, aver);printf (“整数部分之和=%.21f/n“, sumint);printf (“小数部分之和=%.21f/n“, sumdec);WriteDat ( );int ReadDat ()FILE *fp;int j;if(fp=fopen(“in42.dat“,“r“)=NULL)return 1;while (! feof (fp)fscanf (fp, “%f“, if (xxN 0.001) N+;fclose (fp);return 0;void WriteDat

4、)FILE *fp;fp=fopen ( “OUT42.DAT“, “w“);fprintf (fp, “%dkn%.21f/n%.21f/n%.21f/n“, N, aver, sumint, sumdec);fclose (fp);(分数:100.00)_三级网络技术机试-126 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN42.DAT 中存有 N 个实数(N200),函数 ReadDat()读取这 N 个实数并存入数组 xx 中。请编制程序 Ca1Value(),其功能要求:(1)求出这 N 个实数的平均值 ave

5、r。(2)分别求出这 N 个实数的整数部分值之和 sumint 及其小数部分之和 sumdec,最后调用函数 WriteDat()把所求的结果输出到文件 OUT42.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio.h#includeconio.h#define MAXNUM 200float xxMAXNUM;int N=0;double aver=0.0;double sumint=0.0;double sumdec=0.0;int ReadDat( );void Writ

6、eDat( );void CalValue( )void main ( )clrscr ( );if (ReadDat ( ) )printf (“数据文件 IN42.DAT 不能打开! /007/n“);return;CalValue ( );printf (“文件 IN42.DAT 中共有实数%d 个/n“, N);printf (“平均值=%.21f/n“, aver);printf (“整数部分之和=%.21f/n“, sumint);printf (“小数部分之和=%.21f/n“, sumdec);WriteDat ( );int ReadDat ()FILE *fp;int j;

7、if(fp=fopen(“in42.dat“,“r“)=NULL)return 1;while (! feof (fp)fscanf (fp, “%f“, if (xxN 0.001) N+;fclose (fp);return 0;void WriteDat()FILE *fp;fp=fopen ( “OUT42.DAT“, “w“);fprintf (fp, “%dkn%.21f/n%.21f/n%.21f/n“, N, aver, sumint, sumdec);fclose (fp);(分数:100.00)_正确答案:(void CalValue() int i;double x,su

8、m=0.0;for(i=0;iN;i+) sumint=sumint+(int)xxi; /*求整数部分之和*/x=xxi-(int)xxi; /*求每个数的小数部分*/sumdec=sumdec+x; /*求小数部分之和*/sum=sum+xxi; /*求 N 个数之和*/aver=sum/N; /*求 N 个数的平均数*/)解析:解析本题考查的知识点如下;(1)循环结构的使用。(2)强制类型转换。将一个实数的整数部分和小数部分分开,这里使用的方法是强制类型转换法。强制类型转换是按照要求将表达式的值转换成指定的类型。将一个实数强制转换成整型数之后,其小数部分被去掉(不是四舍五入,而是直接删除)。对数组中的 200 个实数求和及平均值,可以使用循环结构。

展开阅读全文
相关资源
猜你喜欢
  • ISO TR 11636-2009 Health Informatics - Dynamic on-demand virtual private network for health information infrastructure《健康信息 健康信息基础架构用动态需求虚拟专用网》.pdf ISO TR 11636-2009 Health Informatics - Dynamic on-demand virtual private network for health information infrastructure《健康信息 健康信息基础架构用动态需求虚拟专用网》.pdf
  • ISO TR 11651-2015 Estimation of sediment deposition in reservoirs using one dimensional simulation models《利用一维仿真模型评估水库中的泥沙淤积》.pdf ISO TR 11651-2015 Estimation of sediment deposition in reservoirs using one dimensional simulation models《利用一维仿真模型评估水库中的泥沙淤积》.pdf
  • ISO TR 11688-1-1995 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Part 1 Planning《声学 低噪声机器和设备设计的推荐实用规程 第1部分 计划》.pdf ISO TR 11688-1-1995 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Part 1 Planning《声学 低噪声机器和设备设计的推荐实用规程 第1部分 计划》.pdf
  • ISO TR 11688-2-1998 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Part 2 Introduction to the physics of low-noise desig.pdf ISO TR 11688-2-1998 Acoustics - Recommended practice for the design of low-noise machinery and equipment - Part 2 Introduction to the physics of low-noise desig.pdf
  • ISO TR 11690-3-1997 Acoustics - Recommended practice for the design of low-noise workplaces containing machinery - Part 3 Sound propagation and noise prediction.pdf ISO TR 11690-3-1997 Acoustics - Recommended practice for the design of low-noise workplaces containing machinery - Part 3 Sound propagation and noise prediction.pdf
  • ISO TR 11696-1-1999 Uses of reaction to fire test results - Part 1 Application of test results to predict fire performance of internal linings and other buildin.pdf ISO TR 11696-1-1999 Uses of reaction to fire test results - Part 1 Application of test results to predict fire performance of internal linings and other buildin.pdf
  • ISO TR 11696-2-1999 Uses of reaction to fire test results - Part 2 Fire hazard assessment of construction products《对火反应试验结果的应用 第2部分 建筑制品火焰危险性的判定》.pdf ISO TR 11696-2-1999 Uses of reaction to fire test results - Part 2 Fire hazard assessment of construction products《对火反应试验结果的应用 第2部分 建筑制品火焰危险性的判定》.pdf
  • ISO TR 11761-1992 Light-gauge metal containers round open-top cans classification of can sizes by construction type《薄壁金属容器 顶开圆罐 按结构类型对罐尺寸的分类》.pdf ISO TR 11761-1992 Light-gauge metal containers round open-top cans classification of can sizes by construction type《薄壁金属容器 顶开圆罐 按结构类型对罐尺寸的分类》.pdf
  • ISO TR 11762-1992 Light-gauge metal containers round open-top cans for liquid products with added gas classification of can sizes by construction type《薄壁金属容器 用于.pdf ISO TR 11762-1992 Light-gauge metal containers round open-top cans for liquid products with added gas classification of can sizes by construction type《薄壁金属容器 用于.pdf
  • 相关搜索

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

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