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

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

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

2、请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#include stdio.h#include stdlib.h#define MAXNUM 200int xxMAXNUM;int totNum=0;/*文件 IN94.DAT 中共有多少个正整数*/int totCnt=0;/*符合条件的正整数的个数*/double totPjz=0.0;/*平均值*/int ReadDat(void);void Writedat(void);void CalValue()void main()int i;system(“CLS“);for(i=0;i

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

4、fscanf(fp,“% d,“,&xxi + +);fclose(fp);return 0;void Writedat(void)FILE * fp;fp=fopen(“OUT94.DAT“,“w“);fprintf(fp,“% d/n% d/n% .21f/n“,totNum,totCnt,totPjz);fclose(fp);(分数:100.00)_三级信息管理技术机试-238 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN94.DAT 中存有若干个(个数200)4 位数字的正整数,函数 ReadDat()的功能是读取

5、这若干个正整数并存入数组 xx 中。请编制函数 CalValue(),其功能要求:(1)求出该文件中共有多少个正整数 totNum;(2)求 m 这些数中的各位数字之和是偶数的数的个数 totCnt,以及满足此条件的这些数的算术平均值 totPjz,最后调用函数 WriteDat()把所求的结果输出到文件 OUT94.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#include stdio.h#include stdlib.h#define MAXNUM 200int xxMAXNUM;int to

6、tNum=0;/*文件 IN94.DAT 中共有多少个正整数*/int totCnt=0;/*符合条件的正整数的个数*/double totPjz=0.0;/*平均值*/int ReadDat(void);void Writedat(void);void CalValue()void main()int i;system(“CLS“);for(i=0;iMAXNUM;i + +)xxi=0;if(Readdat()printf(“数据文件 IN94.DAT 不能打开!/007/n“);return;CalValue();printf(“文件 IN94.DAT 中共有正整数=% d 个/n“,t

7、otNum);printf(“符合条件的正整数的个数=% d 个/n“,totCnt);printf(“平均值=% .21f/n“,totPjz);Writedat();int Readdat(void)FILE * fp;int i=0;if(fp=fopen(“IN94.DAT“,“r“)=NULL)return 1;while(! feof(fp)fscanf(fp,“% d,“,&xxi + +);fclose(fp);return 0;void Writedat(void)FILE * fp;fp=fopen(“OUT94.DAT“,“w“);fprintf(fp,“% d/n% d

8、/n% .21f/n“,totNum,totCnt,totPjz);fclose(fp);(分数:100.00)_正确答案:(void CalValue()int i; /*定义循环控制变量*/int a4,a3,a2,a1; /*用来存储正整数的每一位的数字*/for(i=0;i200;i + +) /*逐个取数组中的数进行统计*/if(xxi0) /*判断是否为正整数*/totNum + +; /*统计正整数的个数*/a4=xxi/1000; /*求正整数的千位数*/a3=xxi%1000/100; /*求正整数的百位数*/a2=xxi%100/10; /*求正整数的十位数*/a1=xxi

9、10; /*求正整数的个位数*/if(a4+a3+a2+a1)%2=0) /*如果各位数字之和是偶数*/ /*计算满足条件的数的个数 totCnt 和这些数的总和 sum*/totCnt + +;totPjz+=xxi;totPjz/=totCnt; /*求这些数的算术平均值 totPjz*/)解析:解析 根据题意,本题的解题思路是首先利用一个 for 循环来依次从数组中取得数,由于题目要求求数组中正整数的个数。只要某个数大于零,则该数一定是正整数,通过变量 totNum 来统计正整数的个数。然后求出该数的每位数字,并判断是否满足条件“各位数字之和是偶数”,用变量 totCnt 和 totPjz 分别计算出满足条件的数的个数和这些数的和 sum。最后求出这些数的平均值。

展开阅读全文
相关资源
猜你喜欢
  • GOST 9 065-1976 Unified system of corrosion and ageing protection Rubbers Test method for liquid corrosive media resistance at the constant tensile stress《ЕСЗКС 橡胶 在恒定拉力下抗腐蚀性液体能力试验.pdf GOST 9 065-1976 Unified system of corrosion and ageing protection Rubbers Test method for liquid corrosive media resistance at the constant tensile stress《ЕСЗКС 橡胶 在恒定拉力下抗腐蚀性液体能力试验.pdf
  • GOST 9 066-1976 Unified system of corrosion and ageing protection Vulcanized rubbers Method of ageing resistance testing under weather conditions《腐蚀和老化联合防护系统 硫化橡胶 在各种天气状况下抗老化性试验法》.pdf GOST 9 066-1976 Unified system of corrosion and ageing protection Vulcanized rubbers Method of ageing resistance testing under weather conditions《腐蚀和老化联合防护系统 硫化橡胶 在各种天气状况下抗老化性试验法》.pdf
  • GOST 9 067-1976 Unified system of corrosion and ageing protection Vulcanized rubbers for articles operating under conditions of thermal and lightozone ageing Techical requirements《.pdf GOST 9 067-1976 Unified system of corrosion and ageing protection Vulcanized rubbers for articles operating under conditions of thermal and lightozone ageing Techical requirements《.pdf
  • GOST 9 068-1976 Unified system of corrosion and ageing protection Sealants Test methods for resistance to attack by liquid corrosive media《腐蚀和老化联合防护系统 密封剂 抗液体腐蚀介质性试验法》.pdf GOST 9 068-1976 Unified system of corrosion and ageing protection Sealants Test methods for resistance to attack by liquid corrosive media《腐蚀和老化联合防护系统 密封剂 抗液体腐蚀介质性试验法》.pdf
  • GOST 9 070-1976 Unified system of corrosion and ageing protection Vulcanized rubbers Test methods for resistance to attack by liquid corrosive media at static compressive strain《腐蚀.pdf GOST 9 070-1976 Unified system of corrosion and ageing protection Vulcanized rubbers Test methods for resistance to attack by liquid corrosive media at static compressive strain《腐蚀.pdf
  • GOST 9 071-1976 Unified system of corrosion and ageing protection Vulcanized rubbers for articles working in liquid corrosive media Technical requirements《ЕСЗКС 在腐蚀性液体中工作的制品用的橡胶 技术.pdf GOST 9 071-1976 Unified system of corrosion and ageing protection Vulcanized rubbers for articles working in liquid corrosive media Technical requirements《ЕСЗКС 在腐蚀性液体中工作的制品用的橡胶 技术.pdf
  • GOST 9 080-1977 Unified system of corrosion and ageing protection Plastic greases Accelerated method for determination of corrosion effect on metals《腐蚀和老化联合防护系统 塑料润滑脂 对金属的腐蚀影响加速测定法.pdf GOST 9 080-1977 Unified system of corrosion and ageing protection Plastic greases Accelerated method for determination of corrosion effect on metals《腐蚀和老化联合防护系统 塑料润滑脂 对金属的腐蚀影响加速测定法.pdf
  • GOST 9 082-1977 Unified protection corrosion and ageing system Oils and lubricants Methods of laboratory tests for resistance to bacteria action《ЕСЗКС 油和润滑油 耐细菌作用的实验室试验法》.pdf GOST 9 082-1977 Unified protection corrosion and ageing system Oils and lubricants Methods of laboratory tests for resistance to bacteria action《ЕСЗКС 油和润滑油 耐细菌作用的实验室试验法》.pdf
  • GOST 9 083-1978 Unified system of corrosion and ageing protection Paint coatings Accelerated test methods for durability in liquid corrosive mediums《腐蚀和老化联合防护系统 油漆涂层 液体腐蚀介质耐久性加速试验法.pdf GOST 9 083-1978 Unified system of corrosion and ageing protection Paint coatings Accelerated test methods for durability in liquid corrosive mediums《腐蚀和老化联合防护系统 油漆涂层 液体腐蚀介质耐久性加速试验法.pdf
  • 相关搜索

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

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