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

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

1、三级网络技术机试-46 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN86.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存入数组 a 中,请编制一函数 jsVal(),其功能是:把千位数字和十位数字重新组合成一个新的十位数 ab(新十位数的十位数字是原 4 位数的千位数字,新十位数的个位数字是原 4 位数的十位数字),以及把个位数字和百位数字组成另一个新的十位数 cd(新十位数的十位数字是原 4 位数的个位数字,新十位数的个位数字是原 4 位数的百位数字),如果新组成的两个十位数 ab

2、cd,ab 必须是偶数且能被 5 整除,cd 必须是奇数,同时两个新十位数字均不为 0,则将满足此条件的 4 位数按从大到小的顺序存入数组 b 中,并要计算满足上述条件的 4 位数的个数 cnt,最后调用写函数 writeDat()把结果 cnt 及数组 b 中符合条件的 4 位数输出到OUT86.DAT 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0

3、void jsVal()void readDat ( )int i;FILE *fp;fp=fopen (“IN86. DAT“, “r“);for (i=0; iMAX;i+)fscanf (fp, “%d“, fclose (fp);main int i;readDat ();jsVal ();printf (“满足条件的数=%d/n“, cnt);for (i=0; icnt; i+)printf(“%d“,bi);printf (“/n“);writeDat ();writeDat ()FILE *fp;int i;fp=fopen (“OUT85. DAT“, “w“);fprin

4、tf (fp, “%d/n“, cnt)for (i=0;icnt; i+)fprintf(fp, “%d/n“,bi);fclose (fp);(分数:100.00)_三级网络技术机试-46 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN86.DAT 中存有 200 个 4 位数,并已调用读函数 readDat()把这些数存入数组 a 中,请编制一函数 jsVal(),其功能是:把千位数字和十位数字重新组合成一个新的十位数 ab(新十位数的十位数字是原 4 位数的千位数字,新十位数的个位数字是原 4 位数的十位数字),以

5、及把个位数字和百位数字组成另一个新的十位数 cd(新十位数的十位数字是原 4 位数的个位数字,新十位数的个位数字是原 4 位数的百位数字),如果新组成的两个十位数 abcd,ab 必须是偶数且能被 5 整除,cd 必须是奇数,同时两个新十位数字均不为 0,则将满足此条件的 4 位数按从大到小的顺序存入数组 b 中,并要计算满足上述条件的 4 位数的个数 cnt,最后调用写函数 writeDat()把结果 cnt 及数组 b 中符合条件的 4 位数输出到OUT86.DAT 文件中。注意:部分源程序已给出。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动主函数 main()、读函

6、数 readDat()和写函数 writeDat()的内容。试题程序:#includestdio.h#define MAX 200int aMAX,bMAX,cnt=0;void jsVal()void readDat ( )int i;FILE *fp;fp=fopen (“IN86. DAT“, “r“);for (i=0; iMAX;i+)fscanf (fp, “%d“, fclose (fp);main int i;readDat ();jsVal ();printf (“满足条件的数=%d/n“, cnt);for (i=0; icnt; i+)printf(“%d“,bi);pr

7、intf (“/n“);writeDat ();writeDat ()FILE *fp;int i;fp=fopen (“OUT85. 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,thou,hun,ten,data, j;int ab,cd;for(i=0;i200;i+)thou=ai/l000; /*求四位数的千位数字*/hun=a i %1000/100; /*求四位数的百位数字*/t

8、en=a i %100/10; /*求四位数的十位数字*/data=a i%10; /*求四位数的个位数字*/ab=thou*10+ten; /*把千位数和十位数重新组合成一个新的十位数字 ab*/cd=data*10+hun; /*把个位数和百位数组合成一个新的十位数字 cd*/if (ab-cd0) /*将满足条件的数存入数组 b 中*/cnt+; /*统计满足条件的数的个数*/for (i=0; icnt-1; i+) /*将数组 b 中的数按从大到小的顺序排列*/for (j=i+l; jcnt; j+)if (bibj)data=b i;b i =b j;b j =data;)解析:

9、解析 本题考查的知识点如下:(1)将一个 4 位整数各位上的数转变成单独的个位数。(2)判断结构中多个条件的布尔运算。(3)循环的使用。(4)数据的排序。在本题中,首先要将一个 4 位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号“%”取余和“/”整除。将 1 个 4 位数整除 1000 则可得到其千位上的数字,将其除以 1000 取余再整除 100 则可得百位上的数字,除以 100 取余再整除 10 则可得十位上的数字,除以 10 取余则得个位上的数字。若一个数除以 2 取余为 0,则这个数是偶数。由题意可知,各个条件必须同时满足,所以各条件之间用“与”运算。先将符合条件的数存入数组 b 中,再对 b 中的数据进行排序。排序采用“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 50564-2011 Electrical and electronic household and office equipment - Measurement of low power consumption (IEC 62301 2011 modified) German version EN 50564 2011《电器及电子家用和办公设.pdf DIN EN 50564-2011 Electrical and electronic household and office equipment - Measurement of low power consumption (IEC 62301 2011 modified) German version EN 50564 2011《电器及电子家用和办公设.pdf
  • DIN EN 50580-2012 Safety of hand-held electric motor operated tools - Particular requirements for spray guns German version EN 50580 2012《手持电动工具的安全 喷枪的特殊要求 德文版本EN 50580-2012》.pdf DIN EN 50580-2012 Safety of hand-held electric motor operated tools - Particular requirements for spray guns German version EN 50580 2012《手持电动工具的安全 喷枪的特殊要求 德文版本EN 50580-2012》.pdf
  • DIN EN 50581-2013 Technical documentation for the assessment of electrical and electronic products with respect to the restriction of hazardous substances German version EN 50581 2.pdf DIN EN 50581-2013 Technical documentation for the assessment of electrical and electronic products with respect to the restriction of hazardous substances German version EN 50581 2.pdf
  • DIN EN 50582-2017 Procedure to assess the circuit integrity of optical fibres in a cable under resistance to fire testing German version EN 50582 2016《评定防火试验下光缆内光纤线路完整性的程序 德文版本EN 5.pdf DIN EN 50582-2017 Procedure to assess the circuit integrity of optical fibres in a cable under resistance to fire testing German version EN 50582 2016《评定防火试验下光缆内光纤线路完整性的程序 德文版本EN 5.pdf
  • DIN EN 50588-1-2016 Medium power transformers 50 Hz with highest voltage for equipment not exceeding 36 kV - Part 1 General requirements German version EN 50588-1 2015《设备最高电压不超过36 .pdf DIN EN 50588-1-2016 Medium power transformers 50 Hz with highest voltage for equipment not exceeding 36 kV - Part 1 General requirements German version EN 50588-1 2015《设备最高电压不超过36 .pdf
  • DIN EN 50600-1-2013 Information technology - Data centre facilities and infrastructures - Part 1 General concepts German version EN 50600-1 2012《信息技术 数据中心设施和基础设施 第1部分 通用概念 德文版本EN 5.pdf DIN EN 50600-1-2013 Information technology - Data centre facilities and infrastructures - Part 1 General concepts German version EN 50600-1 2012《信息技术 数据中心设施和基础设施 第1部分 通用概念 德文版本EN 5.pdf
  • DIN EN 50629-2016 Energy performance of large power transformers (Um  36 kV or Sr = 40 MVA) German version EN 50629 2015《大型电力变压器的能量性能 (Um 36 kV或者Sr≥40 MVA) 德文版本EN 50629-2015》.pdf DIN EN 50629-2016 Energy performance of large power transformers (Um 36 kV or Sr = 40 MVA) German version EN 50629 2015《大型电力变压器的能量性能 (Um 36 kV或者Sr≥40 MVA) 德文版本EN 50629-2015》.pdf
  • DIN EN 50667-2017 Information technology - Automated infrastructure management (AIM) systems - Requirements data exchange and applications German version EN 50667 2016《信息技术 自动化基础设施.pdf DIN EN 50667-2017 Information technology - Automated infrastructure management (AIM) systems - Requirements data exchange and applications German version EN 50667 2016《信息技术 自动化基础设施.pdf
  • DIN EN 55012-2010 Vehicles boats and internal combustion engines - Radio disturbance characteristics - Limits and methods of measurement for the protection of off-board receivers (.pdf DIN EN 55012-2010 Vehicles boats and internal combustion engines - Radio disturbance characteristics - Limits and methods of measurement for the protection of off-board receivers (.pdf
  • 相关搜索

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

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