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

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

1、国家三级(网络技术)机试模拟试卷 199及答案与解析 一、程序设计题 1 文件 IN DAT中存有 200个整数,函数 read_dat(int inBufMAX)负责将这 200个数读到数组 inBuf中。请编制程序,要求;求出数组 inBuf中奇数的个数count1和偶数的个数 count2,以及数组 inBur下标为偶数的元素值的算术平均值average(保留 2位小数 ),结果输出到 OUT DAT中。 部分程序、读函数 read_dat(int inBufMAX)及输出格式已给出。 试题程序; #include #include #define MAX 200 void read_d

2、at(int inBufMAX) int i, j; FILE*fp; fp=fopen(“IN DAT“, “r“); for(i=0; i20; i+) for(j=0; j10; j+) fseanf(fp, “ d, “, &inBufi*10+j); printf(“ d“, inBufi*10+j); printf(“ n“); fclose(fp); void main() int count1, count2, inBufMAX; float average; FILE*fw; int i, k=0; long j; system(“CLS“); fw=fopen(“OUT D

3、AT“, “w“); read_dat(inBuf); average=0; count1=0; count2=0; printf(“ n ncount1= d, count2= d, average= 6 2f n“, countl, count2,average); fprintf(fw, “ dn d n 6 2f n“, eountl, count2, average); fclose(fw); 国家三级(网络技术)机试模拟试卷 199答案与解析 一、程序设计题 1 【正确答案】 for(i=0; iMAX; i+) if(inBufi 2=0)countl+; 如果是偶数,则将计数器 count1加 1 else count2+; 否则,将计数器 count2加 1 if(i 2=0) 如果下标是偶数 average+=inBufi; 则将该数加入总和 k+; 计数器 k加 1 average=average k;求平均值 【试题解析】 本题主要考查依据数组下标对数据进行筛选及平均值的求法。程序步 骤; 1如果 inBufi是奇数,则 countl加 1;否则, count2加 1。如果下标符合条件,则 k加 1,并将 inBufi加到 average上。 2所有数都判断完后average=average k得到平均值。

展开阅读全文
相关资源
猜你喜欢
  • ASTM A608 A608M-2014 Standard Specification for Centrifugally Cast Iron-Chromium-Nickel High-Alloy Tubing for Pressure Application at High Temperatures《高温受压离心铸造的铁铬镍高合金钢管的标准规格》.pdf ASTM A608 A608M-2014 Standard Specification for Centrifugally Cast Iron-Chromium-Nickel High-Alloy Tubing for Pressure Application at High Temperatures《高温受压离心铸造的铁铬镍高合金钢管的标准规格》.pdf
  • ASTM A608 A608M-2014(2018) Standard Specification for Centrifugally Cast Iron-Chromium-Nickel High-Alloy Tubing for Pressure Application at High Temperatures《高温受压离心铸造的铁铬镍高合金钢管的标准规格.pdf ASTM A608 A608M-2014(2018) Standard Specification for Centrifugally Cast Iron-Chromium-Nickel High-Alloy Tubing for Pressure Application at High Temperatures《高温受压离心铸造的铁铬镍高合金钢管的标准规格.pdf
  • ASTM A609 A609M-1991(2002) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《关于超声波检验的低合金、碳和马氏体不锈钢铸件用标准实施规程》.pdf ASTM A609 A609M-1991(2002) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《关于超声波检验的低合金、碳和马氏体不锈钢铸件用标准实施规程》.pdf
  • ASTM A609 A609M-1991(2007) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf ASTM A609 A609M-1991(2007) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf
  • ASTM A609 A609M-2012 Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof 《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf ASTM A609 A609M-2012 Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof 《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf
  • ASTM A609 A609M-2012(2018) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf ASTM A609 A609M-2012(2018) Standard Practice for Castings Carbon Low-Alloy and Martensitic Stainless Steel Ultrasonic Examination Thereof《碳素钢、低合金钢和马氏体不锈钢铸件及其超声波检验的标准实施规程》.pdf
  • ASTM A610-1979(2004) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《尺寸测量用铁合金的取样和试验的标准试验方法》.pdf ASTM A610-1979(2004) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《尺寸测量用铁合金的取样和试验的标准试验方法》.pdf
  • ASTM A610-1979(2009) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《尺寸测量用铁合金的取样和试验的标准试验方法》.pdf ASTM A610-1979(2009) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《尺寸测量用铁合金的取样和试验的标准试验方法》.pdf
  • ASTM A610-1979(2014) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《用于测定尺寸的铁合金的取样和试验的标准试验方法》.pdf ASTM A610-1979(2014) Standard Test Methods for Sampling and Testing Ferroalloys for Determination of Size《用于测定尺寸的铁合金的取样和试验的标准试验方法》.pdf
  • 相关搜索

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

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