【计算机类职业资格】三级网络技术机试-263及答案解析.doc

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

1、三级网络技术机试-263 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN23.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制函数 JsVal(),其功能是:依次从数组 a中取出一个 4位数,如果 4位数连续大于该 4位数以前的 5个数且该数是奇数,该数必须能被 7整除,则统计出满足此条件的数的个数 cnt,并把这些 4位数按从大到小的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到OUT23.DAT文件中。注意:部

2、分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#include stdio.h#define MAX 200int aMAX, bMAX, cnt = 0;void jsVal()void readDat ()int i;FILE *fp;fp = fopen(“IN23.DAT“, “r“for(i=0; iMAX; i+)fscanf(fp, “%d“, main ( )int i;readDat ();jsVal ();printf (“满足条件的数=%d/

3、n“, cnt);for(i=0; icnt; i+)printf(“%d“, bi );printf(“/n“);writeDat ();writeDat ()FILE *fp;int i;fp = fopen(“OUT23.DAT“, “w“);fprintf(fp, “%d/n“, cnt);for(i=0; icnt; i+)fprintf(fp, “%d/n“, bi);fclose (fp);(分数:100.00)_三级网络技术机试-263 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN23.DAT中存有 20

4、0个 4位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制函数 JsVal(),其功能是:依次从数组 a中取出一个 4位数,如果 4位数连续大于该 4位数以前的 5个数且该数是奇数,该数必须能被 7整除,则统计出满足此条件的数的个数 cnt,并把这些 4位数按从大到小的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到OUT23.DAT文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试

5、题程序:#include stdio.h#define MAX 200int aMAX, bMAX, cnt = 0;void jsVal()void readDat ()int i;FILE *fp;fp = fopen(“IN23.DAT“, “r“for(i=0; iMAX; i+)fscanf(fp, “%d“, main ( )int i;readDat ();jsVal ();printf (“满足条件的数=%d/n“, cnt);for(i=0; icnt; i+)printf(“%d“, bi );printf(“/n“);writeDat ();writeDat ()FILE

6、 *fp;int i;fp = fopen(“OUT23.DAT“, “w“);fprintf(fp, “%d/n“, cnt);for(i=0; icnt; i+)fprintf(fp, “%d/n“, bi);fclose (fp);(分数:100.00)_正确答案:(void jsVal()int i, j, flag=0;for(i=5; iMAX; i+) /*如果 4位数连续大于该数以前的 5个数,则置 flag为 1,否则取下一个数*/for(j=i-5; ji; j+)if(aiaj)flag=1;elseflag=0; break;if(flag=1cnt+;fori=0;i

7、cnt-1; i+) /*将数组 b中的数按从大到小的顺序排列*/for(j=i+1; jcnt; i+)if(bibj) flag=bi;bi=bj;bj=flag;)解析:解析 根据题意可知,要编制函数的功能有两部分:一是找出满足条件的 4位数,二是对找出的数进行从大到小排序。首先利用一个 for循环来依次从数组中取得 4位数,接着拿当前得到的 4位数与该数前面的连续的 5个数依次进行比较。如果该数比它前面的 5个数都大,则给标志变量 flag赋值 1,接着对 flag进行判断,如果不为 1,则该数肯定不符合条件,直接去取下一个数。若 flag值为 1,再来判断该数是否是奇数,如果恰好该数又能被 7整除,则把该数添加到数组 b中。这样就可以依次取出符合条件的数。然后利用选择法对数组 b中的元素进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • NC 09-02-10-1986 UESMDSMD Dies Framework Bases with Rectangular Working Surfaces with the Bigger Edge Backward Oriented and Rear Location of Guide Elements Design Specifications《模具.pdf NC 09-02-10-1986 UESMDSMD Dies Framework Bases with Rectangular Working Surfaces with the Bigger Edge Backward Oriented and Rear Location of Guide Elements Design Specifications《模具.pdf
  • NC 09-02-12-1987 UESMDSMD Dies Framework Bases with Circular Working Surfaces and Central Columns Design Specifications《模具统一原理系统 冲模,圆形工作表面和中心圆柱框架底 设计规格》.pdf NC 09-02-12-1987 UESMDSMD Dies Framework Bases with Circular Working Surfaces and Central Columns Design Specifications《模具统一原理系统 冲模,圆形工作表面和中心圆柱框架底 设计规格》.pdf
  • NC 09-02-13-1986 UESMDSMD Dies Ladder Guide Columns Design Specifications《模具统一原理系统 冲模 梯子导向圆柱 设计规格》.pdf NC 09-02-13-1986 UESMDSMD Dies Ladder Guide Columns Design Specifications《模具统一原理系统 冲模 梯子导向圆柱 设计规格》.pdf
  • NC 09-02-15-1987 UESMDSMD Dies Rods Design Specifications《模具统一原理系统 冲模 棒 设计规格》.pdf NC 09-02-15-1987 UESMDSMD Dies Rods Design Specifications《模具统一原理系统 冲模 棒 设计规格》.pdf
  • NC 09-02-18-1986 Unified Elements System of Molds Dies Stampers and Machine Devices Dies Guide Plate with Circular and Rectangular Working Surface Design Specifications《模具统一原理系统 冲模.pdf NC 09-02-18-1986 Unified Elements System of Molds Dies Stampers and Machine Devices Dies Guide Plate with Circular and Rectangular Working Surface Design Specifications《模具统一原理系统 冲模.pdf
  • NC 09-02-1967 Dies and its parts Terminology《冲模和它的零件术语学》.pdf NC 09-02-1967 Dies and its parts Terminology《冲模和它的零件术语学》.pdf
  • NC 09-02-60-1988 Unified Elements System of Moulds Dies Stampers and Machining Devices Dies Separating Washer Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 分开垫圈 设计规格》.pdf NC 09-02-60-1988 Unified Elements System of Moulds Dies Stampers and Machining Devices Dies Separating Washer Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 分开垫圈 设计规格》.pdf
  • NC 09-02-63-1988 Unified Elements System of Moulds Dies Stampers and Machining Devices Dies Safety Hexagonal Nuts Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 安全六边形螺母 设计规格》.pdf NC 09-02-63-1988 Unified Elements System of Moulds Dies Stampers and Machining Devices Dies Safety Hexagonal Nuts Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 安全六边形螺母 设计规格》.pdf
  • NC 09-02-74-1988 Uhified Elements System of Mbulds Dies Stampers and Machining Devices Dies Separating Slotted Screw Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 分开有槽螺钉设计规格》.pdf NC 09-02-74-1988 Uhified Elements System of Mbulds Dies Stampers and Machining Devices Dies Separating Slotted Screw Design Specifications《模具统一原理系统 冲模,压模和机械装置 冲模 分开有槽螺钉设计规格》.pdf
  • 相关搜索

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

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