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

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

1、国家三级(网络技术)机试模拟试卷 53及答案与解析 一、程序设计题 1 已知数据文件 IN53.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 isVal(),其功能是:依次从数组 a中取出一个 4位数,如果该 4位数连续大于该 4位数以前的 5个数且该数是偶数,则统计出满足此条件的数个数 cnt并把这些 4位数按从大到小的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到文件 OUT53.DAT中。 请勿改动主函数 main()、读函数 readDat()和写函数 wiltedat

2、)的内容。 试题程序: #include stdio.h #define MAX 200 int aMAX,bMAX,cnt=0; void jsVal() void readDat() int i; FILE *fp; fp=fopen(“in53.dat“,“r“); for(i=0;i MAX;i+) fscanf(fp,“%d“, fclose(fp); void main() int i; readDat(); jsVal(); printf (“满足条件的数 =%dn“, cnt); for(i=0;i cnt;i+) printf(“%d“,bi); printf(“n“);

3、writeDat(); writeDat() FILE *fp; int i; fp=foPen(“out53.dat“,“w“); fprintf(fp,“%dn“,cnt); for(i=0;i cnt;i+) fprintf(fp,“%dn“,bi); fclose(fp); 国家三级(网络技术)机试模拟试卷 53答案与解析 一、程序设计题 1 【正确答案】 void jsVal() int i,j,flag; for (i=5; i MAX; i+) for(j=i-5;j i;j+) if(ai aj) /*如果该 4位数连续大于它以前的 5个数 */ flag=l; /*则置 fl

4、ag为 1*/ else flag=0; /*否则置 flag为 0*/ if (ai%2!=0) /*如果该四位数为奇数 */ flag=0; /*则 置 flag为 0*/ if (flag=O) break; /*如果 flag为 0, 则退出循环 */ if (flag=1) bcnt =ai; /*把满足条件的数存入数组 b中 */ cnt+; /*统计满足条件的数的个数 */ for (i=0; i cnt-1; i+) /*将数组 b中的数按从大到波折顺序排列 */ for ( j =i+l; j cnt; j +) if(bi bj ) flag=bi; bi=bj; bj=flag; 【试题解析】 本题考查的知识点如下: (1)使用循环对数组的元素进行比较和排序。 (2)强行退出循环结构。 在本题中,数组 b中的数据要满足的条件有两个。在这里,不再使用判断结构中条件的布尔运算,而采用一种新的方法 设置标志变量 flag。当数据不满足某一条件时,如数据不是偶数,将 flag设置为 0:当 flag等于 0时,可直接退出本层循环结构,进入外层的循环中。否则,根据题意要求,将数据存入数组 b中。对数组 b中的数据排序,使用 “选择排序法 ”。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO 8513-2016 Plastics piping systems Glass-reinforced thermosetting plastics (GRP) pipes Test methods for the determination of the initial longitudinal tensile strengt.pdf BS ISO 8513-2016 Plastics piping systems Glass-reinforced thermosetting plastics (GRP) pipes Test methods for the determination of the initial longitudinal tensile strengt.pdf
  • BS ISO 8514-1-2000 Micrographics - Alphanumeric computer output microforms - Quality control - Characteristics of the test slide and test data《缩微摄影技术 字母数字计算机输出缩微品 质量控制 试验滑.pdf BS ISO 8514-1-2000 Micrographics - Alphanumeric computer output microforms - Quality control - Characteristics of the test slide and test data《缩微摄影技术 字母数字计算机输出缩微品 质量控制 试验滑.pdf
  • BS ISO 8514-2-2000 Micrographics - Alphanumeric computer output microforms - Quality control - Method《缩微摄影技术 字母数字计算机输出缩微品 质量控制 方法》.pdf BS ISO 8514-2-2000 Micrographics - Alphanumeric computer output microforms - Quality control - Method《缩微摄影技术 字母数字计算机输出缩微品 质量控制 方法》.pdf
  • BS ISO 8516-2011 Textile glass Textured yarns Basis for a specification《纺织玻璃纤维 膨体纱 基本规格》.pdf BS ISO 8516-2011 Textile glass Textured yarns Basis for a specification《纺织玻璃纤维 膨体纱 基本规格》.pdf
  • BS ISO 8518-2005 Workplace air - Determination of particulate lead and lead compounds - Flame or electrothermal atomic absorption spectrometric method《工作场所空气 铅颗粒及铅化合物的测定 火.pdf BS ISO 8518-2005 Workplace air - Determination of particulate lead and lead compounds - Flame or electrothermal atomic absorption spectrometric method《工作场所空气 铅颗粒及铅化合物的测定 火.pdf
  • BS ISO 8525-2008 Airborne noise emitted by machine tools - Operating conditions for metal-cutting machines《机械工具发出的空气噪声 金属切割机的运行条件》.pdf BS ISO 8525-2008 Airborne noise emitted by machine tools - Operating conditions for metal-cutting machines《机械工具发出的空气噪声 金属切割机的运行条件》.pdf
  • BS ISO 8528-2-2006 Reciprocating internal combustion engine driven alternating current generating sets - Engines《往复式内燃机驱动的交流发电装置 发动机》.pdf BS ISO 8528-2-2006 Reciprocating internal combustion engine driven alternating current generating sets - Engines《往复式内燃机驱动的交流发电装置 发动机》.pdf
  • BS ISO 8528-3-2006 Reciprocating internal combustion engine driven alternating current generating sets - Alternating current generators for generating sets《往复式内燃机驱动的交流发电装置.pdf BS ISO 8528-3-2006 Reciprocating internal combustion engine driven alternating current generating sets - Alternating current generators for generating sets《往复式内燃机驱动的交流发电装置.pdf
  • BS ISO 8528-4-2006 Reciprocating internal combustion engine driven alternating current generating sets - Controlgear and switchgear《往复式内燃机驱动的交流发电装置 控制设备和开关设备》.pdf BS ISO 8528-4-2006 Reciprocating internal combustion engine driven alternating current generating sets - Controlgear and switchgear《往复式内燃机驱动的交流发电装置 控制设备和开关设备》.pdf
  • 相关搜索

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

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