[计算机类试卷]国家三级(网络技术)机试模拟试卷241及答案与解析.doc

上传人:dealItalian200 文档编号:495757 上传时间:2018-11-28 格式:DOC 页数:3 大小:27KB
下载 相关 举报
[计算机类试卷]国家三级(网络技术)机试模拟试卷241及答案与解析.doc_第1页
第1页 / 共3页
[计算机类试卷]国家三级(网络技术)机试模拟试卷241及答案与解析.doc_第2页
第2页 / 共3页
[计算机类试卷]国家三级(网络技术)机试模拟试卷241及答案与解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(网络技术)机试模拟试卷 241及答案与解析 一、程序设计题 1 已知在文件 IN DAT中存有若干个 (个数 #include #define MAX 200 int inBufMAX; int totleNum=0; *文件 IN DAT中共有多少个正整数 * int totleCnt=0; *符合条件的正整数的个数 * double totleAverage=0 0;平均值 int ReadData(void); void WriteData(void); void findValue(void) void main() int i; system(“CLS“); for(i=0

2、 iMAX; i+) inBufi=0; if(ReadData() printf(“IN DAT cant be opened! 007 n“); return; findValue(); printf(“totleNum= d n“, totleNum); printf(“totleCnt= d n“, totleCnt); printf(“totleAverage= 21f n“, totleAverage); WriteData(); int ReadData(void) FILE*fp; int i=0; if(fp=fopen(“IN DAT“, “r“)=NULL) retur

3、n 1; while(!feof(fp) fscanf(fp, “ d, “, &inBufi+); fclose(fp); return 0; void WriteData(void) FILE*fp; fp=fopen(“OUT DAT“, “w“); fprintf(fp, “ d n d n 21f n“, totleNum, totleCnt, totleAverage); fclose(fp); 国家三级(网络技术)机试模拟试卷 241答案与解析 一、程序设计题 1 【正确答案 】 void findValue(void) int i; for(i=0; iMAX; i+) if(

4、inBufi 0)totleNum+; 如果是正数就将计数器 totleNum加 1 if(inBufi 2) 2=0) 如果右移一位后生成的数据是偶数 totleCnt+; 将计数器 totleCnt加 1 求满足条件的数的均值, totleAverage*(totleCnt-1)是前 totleCnt-1个数的总和 totleAverage=(totleAverage*(totleCnt-1)+inBufi) totleCnt; 【试题解析】 本题主要考查数据移位、奇偶判断及平均值求法。 1数据移位;数据左移一位相当于将数据乘以 2,数据右移一位相当于将数据除以 2。 2奇偶判断;如果一个数对 2求余结果为 0,则该数为偶数;否则,为奇数。 3求平均值;由于本题中的数据量比较大,若采用先将各个值加起来再除以总个数来取平均的话,变 量不能存储那么大的数据而导致溢出。本题的程序采用的方法是; N个数的平均值 =前 (N-1)个数的平均值 *(N-1)+第 N个数 N,采用这种递推的方法就避免了将大的数据存入变量中而产生溢出。

展开阅读全文
相关资源
猜你喜欢
  • BS PD CEN TR 15339-5-2014 Thermal spraying Safety requirements for thermal spraying equipment Powder and wire feed units《热喷涂 热喷涂设备的安全要求 粉末和送丝装置》.pdf BS PD CEN TR 15339-5-2014 Thermal spraying Safety requirements for thermal spraying equipment Powder and wire feed units《热喷涂 热喷涂设备的安全要求 粉末和送丝装置》.pdf
  • BS PD CEN TR 15339-6-2014 Thermal spraying Safety requirements for thermal spraying equipment Spray booth Handling system Dust collection Exhaust system Filter《热喷涂 热喷涂设备的安.pdf BS PD CEN TR 15339-6-2014 Thermal spraying Safety requirements for thermal spraying equipment Spray booth Handling system Dust collection Exhaust system Filter《热喷涂 热喷涂设备的安.pdf
  • BS PD CEN TR 15349-2006 Hardware for furniture — Terms for extension elements and their components 《家具用五金件 延伸件及其部件用术语》.pdf BS PD CEN TR 15349-2006 Hardware for furniture — Terms for extension elements and their components 《家具用五金件 延伸件及其部件用术语》.pdf
  • BS PD CEN TR 15350-2013 6796 Mechanical vibration Guideline for the assessment of exposure to hand-transmitted vibration using available information including that provided by man.pdf BS PD CEN TR 15350-2013 6796 Mechanical vibration Guideline for the assessment of exposure to hand-transmitted vibration using available information including that provided by man.pdf
  • BS PD CEN TR 15351-2006 Plastics — Guide for vocabulary in the field of degradable and nbiodegradable polymers and plastic items《塑料 可降解的和可生物降解的聚合物和塑料产品领域的术语指南》.pdf BS PD CEN TR 15351-2006 Plastics — Guide for vocabulary in the field of degradable and nbiodegradable polymers and plastic items《塑料 可降解的和可生物降解的聚合物和塑料产品领域的术语指南》.pdf
  • BS PD CEN TR 15356-1-2006 Validation and interpretation of analytical methods migration testing and analytical data for materials and articles in contact with food — Part .pdf BS PD CEN TR 15356-1-2006 Validation and interpretation of analytical methods migration testing and analytical data for materials and articles in contact with food — Part .pdf
  • BS PD CEN TR 15367-1-2014 Petroleum products Guidelines for good housekeeping Automotive diesel fuels《石油产品 良好家务管理指南 第1部分 机动车用柴油燃料》.pdf BS PD CEN TR 15367-1-2014 Petroleum products Guidelines for good housekeeping Automotive diesel fuels《石油产品 良好家务管理指南 第1部分 机动车用柴油燃料》.pdf
  • BS PD CEN TR 15367-2-2007 Petroleum products — Guide for good housekeeping — nPart 2 Automotive petrol fuels《石油产品 优质家务管理指南 第2部分 机动车汽油燃料》.pdf BS PD CEN TR 15367-2-2007 Petroleum products — Guide for good housekeeping — nPart 2 Automotive petrol fuels《石油产品 优质家务管理指南 第2部分 机动车汽油燃料》.pdf
  • BS PD CEN TR 15371-2-2017 Safety of toys Interpretations Replies to requests for interpretation of the chemical standards in the EN 71-series《玩具的安全性 解释 对EN 71系列中化学标准解释要求的答.pdf BS PD CEN TR 15371-2-2017 Safety of toys Interpretations Replies to requests for interpretation of the chemical standards in the EN 71-series《玩具的安全性 解释 对EN 71系列中化学标准解释要求的答.pdf
  • 相关搜索

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

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