【计算机类职业资格】三级信息管理技术机试-151及答案解析.doc

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

1、三级信息管理技术机试-151 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN65.DAT中存有若干个(个数200)4 位数字的正整数,函数 ReadDat()是读取这若干个正整数并存入数组 xx中。请编制函数 CalValue(),其功能要求是: (1)求出这个文件中共有多少个正整数totNum。 (2)求出这些数中的各位数字之和是奇数的个数 totCnt,以及满足此条件的这些数的算术平均值 totPjz。最后调用函数 WriteDat()把所有结果输出到文件 OUT65.DAT 中。注意:部分源程序已给出。 请勿改动主函

2、数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio. h#includeconio. h#define MAXNUM 200int xx MAXNUM;int totNum=0;int totCnt=0;double totPjz=0.0;int ReadDat (void);void WriteDat (void)void CalValue (void)void main ( )int i;clrscr ( );for ( i=0; iMAXNUM; i+ )xxi=0;if (ReadDat ( ) )printf (“数

3、据文件 IN65.DAT不能打开! /007/“)return;CalValue ( );printf ( “文件 IN65.DAT中共有正整数=%d 个/n“,totNum);printf ( “符合条件的正整数的个数=%d 个/n“, totCnt)printf ( “平均值=%. 21f/n“, totPjz);WriteDat ();int ReadDat (void)FILE *fp;int i=0;if ( ( fp= fopen ( “IN65. DAT“, “r“ ) ) =NULL)return 1;while ( ! feof (fp)fscanf (fp, “%d“, f

4、close (fp);return 0;void WriteDat (void)FILE *fp;fp=fopen (“OUT65. DAT“, “w“ );fprint f (fp, “%d/n%d/n%. 21f/n“, totNum, totCnt,totPjz);fclose (fp);(分数:100.00)_三级信息管理技术机试-151 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN65.DAT中存有若干个(个数200)4 位数字的正整数,函数 ReadDat()是读取这若干个正整数并存入数组 xx中。请编制函数

5、CalValue(),其功能要求是: (1)求出这个文件中共有多少个正整数totNum。 (2)求出这些数中的各位数字之和是奇数的个数 totCnt,以及满足此条件的这些数的算术平均值 totPjz。最后调用函数 WriteDat()把所有结果输出到文件 OUT65.DAT 中。注意:部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio. h#includeconio. h#define MAXNUM 200int xx MAXNUM;int totNum=0;int totCnt=0;doubl

6、e totPjz=0.0;int ReadDat (void);void WriteDat (void)void CalValue (void)void main ( )int i;clrscr ( );for ( i=0; iMAXNUM; i+ )xxi=0;if (ReadDat ( ) )printf (“数据文件 IN65.DAT不能打开! /007/“)return;CalValue ( );printf ( “文件 IN65.DAT中共有正整数=%d 个/n“,totNum);printf ( “符合条件的正整数的个数=%d 个/n“, totCnt)printf ( “平均值=

7、 21f/n“, totPjz);WriteDat ();int ReadDat (void)FILE *fp;int i=0;if ( ( fp= fopen ( “IN65. DAT“, “r“ ) ) =NULL)return 1;while ( ! feof (fp)fscanf (fp, “%d“, fclose (fp);return 0;void WriteDat (void)FILE *fp;fp=fopen (“OUT65. DAT“, “w“ );fprint f (fp, “%d/n%d/n%. 21f/n“, totNum, totCnt,totPjz);fclos

8、e (fp);(分数:100.00)_正确答案:(void CalValue (void)int i, thou, hun, ten, data;for (i=O; iMAXNUM; i+)if(!xxi) break;if (xxi 0)totNum+; /*求正整数的个数*/thou=xx i/1000; /*求四位数的千位数字*/hun=xx i %1000/100; /*求四位数的百位数字* /ten=xx i %1 O0/10; /*求四位数的十位数字*/data=xx i %10; /*求四位数的个位数字*/if (thou+hun+ten+data) %2 )totCnt+; /*求数字之和是奇数的个数*/totPjz+=xxi; /*求满足条件的数的平均数* /totPjz/=totCnt; /*求满足条件的数的平均值*/)解析:解析 本题考查的知识点如下:(1)“%”与“/”的使用。(2)数组结束的判断和强行退出一层循环结构。在本题中,并没有给出确切的数据个数,是以数据的最大个数定义的数组。在主函数中,给所有的数组成员赋初值为 0,而从文件中读取的数据是正整数,所以只要数组的某个元素为 0,则说明数组存的数据已经结束。此时就可以结束循环结构。这里要借助运算符“%”与“/”将 4位数的各位上的数拆成独立的数字,然后就可以根据题意要求判断。

展开阅读全文
相关资源
猜你喜欢
  • IEC 60393-4-1992 Potentiometers for use in electronic equipment part 4 sectional specification single-turn rotary power potentiometers《电子设备用电位器 第4部分 分规范 单圈旋转功率电位器》.pdf IEC 60393-4-1992 Potentiometers for use in electronic equipment part 4 sectional specification single-turn rotary power potentiometers《电子设备用电位器 第4部分 分规范 单圈旋转功率电位器》.pdf
  • IEC 60393-4-2-1992 Potentiometers for use in electronic equipment part 4 blank detail specification singel-turn rotary power potentiometers assessment level F《电子设备用电位器 第4-2部分 空白详细规范 单圈旋转功率电位器 评定水平.pdf IEC 60393-4-2-1992 Potentiometers for use in electronic equipment part 4 blank detail specification singel-turn rotary power potentiometers assessment level F《电子设备用电位器 第4-2部分 空白详细规范 单圈旋转功率电位器 评定水平.pdf
  • IEC 60393-6-1-2003 Potentiometers for use in electronic equipment - Part 6-1 Blank detail specification Surface mount preset potentiometers Assessment level E《电子设备用电位器.第6-1部分 空白详细规范 表面安装预调电位器》.pdf IEC 60393-6-1-2003 Potentiometers for use in electronic equipment - Part 6-1 Blank detail specification Surface mount preset potentiometers Assessment level E《电子设备用电位器.第6-1部分 空白详细规范 表面安装预调电位器》.pdf
  • IEC 60393-6-2015 Potentiometers for use in electronic equipment - Part 6 Sectional specification - Surface mount preset potentiometers《电子设备用电位器.第6部分 分规范 表面安装预调电位器》.pdf IEC 60393-6-2015 Potentiometers for use in electronic equipment - Part 6 Sectional specification - Surface mount preset potentiometers《电子设备用电位器.第6部分 分规范 表面安装预调电位器》.pdf
  • IEC 60394-1-1972 Varnished fabrics for electrical purposes Part 1  Definitions and general requirements《电工用浸渍织物 第1部分 定义和一般要求》.pdf IEC 60394-1-1972 Varnished fabrics for electrical purposes Part 1 Definitions and general requirements《电工用浸渍织物 第1部分 定义和一般要求》.pdf
  • IEC 60394-2-1972 Varnished fabrics for electrical purposes Part 2  Methods of test《电工用浸渍织物 第2部分 试验方法》.pdf IEC 60394-2-1972 Varnished fabrics for electrical purposes Part 2 Methods of test《电工用浸渍织物 第2部分 试验方法》.pdf
  • IEC 60394-3-2-1988 Varnished fabrics for electrical purposes Part 3 Specifications for individual materials Sheet 2  Glass-fibre based varnished fabrics with epoxy polyurethane sil.pdf IEC 60394-3-2-1988 Varnished fabrics for electrical purposes Part 3 Specifications for individual materials Sheet 2 Glass-fibre based varnished fabrics with epoxy polyurethane sil.pdf
  • IEC 60398-2015 Installations for electroheating and electromagnetic processing - General performance test methods《电热和电磁加工用装置 通用性能试验方法》.pdf IEC 60398-2015 Installations for electroheating and electromagnetic processing - General performance test methods《电热和电磁加工用装置 通用性能试验方法》.pdf
  • IEC 60399 Edition 2.1-2008 Barrel thread for lampholders with shade holder ring《带灯罩卡环的灯座的圆筒螺纹》.pdf IEC 60399 Edition 2.1-2008 Barrel thread for lampholders with shade holder ring《带灯罩卡环的灯座的圆筒螺纹》.pdf
  • 相关搜索

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

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