【计算机类职业资格】三级信息管理技术机试-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位数的各位上的数拆成独立的数字,然后就可以根据题意要求判断。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 12350-5-2009 Testing fresh concrete - Part 5 Flow table test English version of DIN EN 12350-5 2009-08《新拌混凝土试验 第5部分 流动性试验 英文版本DIN EN 12350-5-2009-08》.pdf DIN EN 12350-5-2009 Testing fresh concrete - Part 5 Flow table test English version of DIN EN 12350-5 2009-08《新拌混凝土试验 第5部分 流动性试验 英文版本DIN EN 12350-5-2009-08》.pdf
  • DIN EN 12350-6-2011 Testing fresh concrete - Part 6 Density German version EN 12350-6 2009《新拌混凝土试验 第6部分 密度 德文版本EN 12350-6-2009》.pdf DIN EN 12350-6-2011 Testing fresh concrete - Part 6 Density German version EN 12350-6 2009《新拌混凝土试验 第6部分 密度 德文版本EN 12350-6-2009》.pdf
  • DIN EN 12350-7-2009 Testing fresh concrete - Part 7 Air content - Pressure methods English version of DIN EN 12350-7 2009-08《新拌混凝土试验 第7部分 空气含量 压力法 英文版本DIN EN 12350-7-2009-08》.pdf DIN EN 12350-7-2009 Testing fresh concrete - Part 7 Air content - Pressure methods English version of DIN EN 12350-7 2009-08《新拌混凝土试验 第7部分 空气含量 压力法 英文版本DIN EN 12350-7-2009-08》.pdf
  • DIN EN 12350-8-2010 Testing fresh concrete - Part 8 Self-compacting concrete - Slump-flow test German version EN 12350-8 2010《新浇混凝土试验 第8部分 自密实混凝土 德文版本EN 12350-8-2010》.pdf DIN EN 12350-8-2010 Testing fresh concrete - Part 8 Self-compacting concrete - Slump-flow test German version EN 12350-8 2010《新浇混凝土试验 第8部分 自密实混凝土 德文版本EN 12350-8-2010》.pdf
  • DIN EN 12350-9-2010 Testing fresh concrete - Part 9 Self-compacting concrete - V-funnel test German version EN 12350-9 2010《新浇混凝土试验 第9部分 自密实混凝土 V形漏斗试验 德文版本EN 12350-9-2010》.pdf DIN EN 12350-9-2010 Testing fresh concrete - Part 9 Self-compacting concrete - V-funnel test German version EN 12350-9 2010《新浇混凝土试验 第9部分 自密实混凝土 V形漏斗试验 德文版本EN 12350-9-2010》.pdf
  • DIN EN 12351-2010 Industrial valves - Protective caps for valves with flanged connections German version EN 12351 2010《工业阀门 带法兰联接的阀门用护罩 德文版本EN 12351-2010》.pdf DIN EN 12351-2010 Industrial valves - Protective caps for valves with flanged connections German version EN 12351 2010《工业阀门 带法兰联接的阀门用护罩 德文版本EN 12351-2010》.pdf
  • DIN EN 12352-2006 Traffic control equipment - Warning and safety light devices English version of DIN EN 12352 2006-07《交通管制设备 告警和安全灯装置》.pdf DIN EN 12352-2006 Traffic control equipment - Warning and safety light devices English version of DIN EN 12352 2006-07《交通管制设备 告警和安全灯装置》.pdf
  • DIN EN 12353-2013 en 9586 Chemical disinfectants and antiseptics - Preservation of test organisms used for the determination of bactericidal (including Legionella) mycobactericidal.pdf DIN EN 12353-2013 en 9586 Chemical disinfectants and antiseptics - Preservation of test organisms used for the determination of bactericidal (including Legionella) mycobactericidal.pdf
  • DIN EN 12354-5-2009 Building acoustics - Estimation of acoustic performance of building from the performance of elements - Part 5 Sounds levels due to the service equipment English.pdf DIN EN 12354-5-2009 Building acoustics - Estimation of acoustic performance of building from the performance of elements - Part 5 Sounds levels due to the service equipment English.pdf
  • 相关搜索

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

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