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

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

1、国家三级(网络技术)机试模拟试卷 210及答案与解析 一、程序设计题 1 文件 IN DAT中存有 200个四位整型数,函数 readData()负责将 IN DAT中的数读到数组 inBuf中。请编制一函数 findData(),其功能是;依次从数组 inBuf中取出一个四位数,如果该四位数连续大于该四位数以前的 5个数且该数是偶数 (该四位数前面不满 5个数,则不统计 ),则按照从大到小的顺序存人数组 outBuf中,并用 count记录下符合条件的数的个数。函数 writeData()负责将 outBuf中的数输出 到文件 OUT DAT中并且在屏幕上显示出来。 注意;部分源程序已给出。

2、 程序中已定义数组; inBuf200, outBuf200,已定义变量; count。 请勿改动主函数 main()、读函数 readData()和写函数 writeData()的内容。 试题程序; #include #define MAX 200 int inBufMAX, outBufMAX, count=0; void findData() void readData() int i; FILE*fp; fp=fopen(“IN DAT“, “r“); for(i=0; iMAX; i+) fscanf(fp, “ d“, &inBufi); fclose(fp); void writ

3、eData() FILE*fp; int i; fp=fopen(“OUT DAT“, “w“); fprintf(fp, “ d n“, count); for(i=0; icount; i+) fprintf(fp, “ d n“, outBufi); fclose(fp); void main() int i; readData(); findData(); printf(“the count of desired datas= d n“, count); for(i=0; icount; i+) printf(“ d n“, outBufi); printf(“ n“); writeD

4、ata(); 国家三级(网络技术)机试模拟试卷 210答案与解析 一、程序设计题 1 【正确答案】 void findData() int i, j, temp, flag; count=0; for(i=5; iMAX; i+) 逐行取每个四位数 if(inBufi 2=o) 若当前数是偶数 flag=0; for(j=i-5; j=i-1; j+) *如果当前数据比其前 5个数中的一个要小,则将标志置 1,以示不满足要求 * if(inBufi=inBufj)flag=1; if(flag=0) outBufcount=inBufi;将满足要求的数存人 outBuf中 count+; 将计

5、数器加 1 for(i=0; icount-1; i+) 以下是对数据进行从大到小 ,的排序 for(j=i+1; jcount; j+) if(outBufioutBufj) 如果第 i位比它后面的数小 则将两者进行交换,也即将更大的数放到第 i位 temp=outBufi; outBufi=outBufj; outBufj=temp; 【试题解析】 本题考查的主要是数据的奇偶性判断及数组的排序。基本思路是;1查找符合要求的数,利用条件 inBufi 2=0找出偶数。用该数与其前面的连续 5个数相比较,如果有一个数不符合要求 (小于或等于后面的数 ),则可将该数排除,这样一来便可找出所有符合要求的数。 2将当前数与其后的各个数相比较,如果当前的数比其后的数据小,则将两数据进行交换,从而使得前面的数据大于后面的数据,最终达到从 大到小排序的目的。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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