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

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

1、三级网络技术机试-129 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN77.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsVal(),其功能是:如果一个 4位数的干位数字上的值加十位数字上的值恰好等于百位数字上的值加上个位数字上的值,并且此 4位数是偶数,则统计满足此条件的数的个数 cnt并把这些 4位数按从小到大的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到 OUT77. DAT文件中。注意:部

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

3、printf (“满足条件的数=%d/n“, cnt)for (i=0; icnt; i+)printf (“%d“,b i );printf (“/n“);writeDat ();writeDat ()FILE *fp;int i;fp= fopen ( “OUT7 7. DAT“, “w“ );fprint f (fp, “%od/n“, cnt);for (i=0;icnt; i+)fprintf(fp, “%d/n“,bi);fclose (fp);(分数:100.00)_三级网络技术机试-129 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100

4、00)1.已知数据文件 IN77.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsVal(),其功能是:如果一个 4位数的干位数字上的值加十位数字上的值恰好等于百位数字上的值加上个位数字上的值,并且此 4位数是偶数,则统计满足此条件的数的个数 cnt并把这些 4位数按从小到大的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt及数组 b中符合条件的 4位数输出到 OUT77. DAT文件中。注意:部分源程序已给出。程序中已定义数组:a200, b200, 已定义变量:cnt。请勿改动主函数 main()、读函数

5、readDat()和写函数 writeDat()的内容。试题程序:#includestdio. h#define MAX 200int aMAX ,bMAX ,cnt=0;void jsVal( )void readDat ( )int i;FILE *fp;fp=fopen ( “IN77. 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“

6、b i );printf (“/n“);writeDat ();writeDat ()FILE *fp;int i;fp= fopen ( “OUT7 7. DAT“, “w“ );fprint f (fp, “%od/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; iMAX; i+)thou=a i/1000; /*求四位数的千位数字*/hun=a i

7、 %1000/100; /*求四位数的百位数字*/ten=a i %100/10; /*求四位数的十位数字*/data=a i %10; /*求四位数的个位数字*/if (thou+ten=hun+data) /*则将满足条件的数存入数组 b中*/cnt+; /*统计满足条件的数的个数*/for (i=0; icnt-1; i+) /*将数组 b中的数按从小到大的顺序排列*/for (j=i+1; jcnt; j+)if (bibj)da ta=b i;bi=bj;b j =data;)解析:解析 本题考查的知识点如下:(1)将一个 4位整数各位上的数转变成单独的个位数。(2)判断结构中多个条件的布尔运算。(3)数据的排序。在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号“%” (取余)和“/” (整除)。将一们位数整除 1000则可得到其千位上的数字,除以 1000取余再整除100则可得百位上的数字,除以 100取余再整除 10则可得卜位上的数字,除以 10取余则得个位上的数字。若一个数除以 2取余为 0,则这个数是偶数。题目中的两个条件必须同时满足,所以两条件之间用“与”运算。先将满足条件的数存入数组 b中,再对数组中的数据进行排序。最后的排序采用“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • DIN ISO 7876-3-1995 Fuel injection equipment - Vocabulary - Part 3 Unit injectors identical with ISO 7876-3 1993《燃料喷射装置 词汇 第3部分 单元式喷射器 等同采用 ISO 7876-3 1993》.pdf DIN ISO 7876-3-1995 Fuel injection equipment - Vocabulary - Part 3 Unit injectors identical with ISO 7876-3 1993《燃料喷射装置 词汇 第3部分 单元式喷射器 等同采用 ISO 7876-3 1993》.pdf
  • DIN ISO 7879-1992 Road vehicles cradle-mounted in-line fuel injection pumps mounting dimensions identical with ISO 7879 1990《道路车辆 托架安装的直列柱塞燃油喷射泵 安装尺寸》.pdf DIN ISO 7879-1992 Road vehicles cradle-mounted in-line fuel injection pumps mounting dimensions identical with ISO 7879 1990《道路车辆 托架安装的直列柱塞燃油喷射泵 安装尺寸》.pdf
  • DIN ISO 7884-1-1998 Glass - Viscosity and viscometric fixed points - Part 1 Principles for determining viscosity and viscometric fixed points (ISO 7884-1 1987)《玻璃 粘度和粘度固定点 第1部分 粘度和.pdf DIN ISO 7884-1-1998 Glass - Viscosity and viscometric fixed points - Part 1 Principles for determining viscosity and viscometric fixed points (ISO 7884-1 1987)《玻璃 粘度和粘度固定点 第1部分 粘度和.pdf
  • DIN ISO 7884-2-1998 Glass - Viscosity and viscometric fixed points - Part 2 Determination of viscosity by rotation viscometers (ISO 7884-2 1987)《玻璃 粘度和粘度固定测定点 第2部分 用转动粘度计测定粘度》.pdf DIN ISO 7884-2-1998 Glass - Viscosity and viscometric fixed points - Part 2 Determination of viscosity by rotation viscometers (ISO 7884-2 1987)《玻璃 粘度和粘度固定测定点 第2部分 用转动粘度计测定粘度》.pdf
  • DIN ISO 7884-3-1998 Glass - Viscosity and viscometric fixed points - Part 3 Determination of viscosity by fibre elongation viscometer (ISO 7884-3 1987)《玻璃 粘度和粘度固定点 第3部分 纤维伸长粘度计测定粘度.pdf DIN ISO 7884-3-1998 Glass - Viscosity and viscometric fixed points - Part 3 Determination of viscosity by fibre elongation viscometer (ISO 7884-3 1987)《玻璃 粘度和粘度固定点 第3部分 纤维伸长粘度计测定粘度.pdf
  • DIN ISO 7884-4-1998 Glass - Viscosity and viscometric fixed points - Part 4 Determination of viscosity by beam bending (ISO 7884-4 1987)《玻璃 粘度和粘度固定点 第4部分 射线束弯曲法测定粘度》.pdf DIN ISO 7884-4-1998 Glass - Viscosity and viscometric fixed points - Part 4 Determination of viscosity by beam bending (ISO 7884-4 1987)《玻璃 粘度和粘度固定点 第4部分 射线束弯曲法测定粘度》.pdf
  • DIN ISO 7884-5-1998 Glass - Viscosity and viscometric fixed points - Part 5 Determination of working point by sinking bar viscometer (ISO 7884-5 1987)《玻璃 粘度和粘度固定点 第5部分 沉棒粘度计测定工作点》.pdf DIN ISO 7884-5-1998 Glass - Viscosity and viscometric fixed points - Part 5 Determination of working point by sinking bar viscometer (ISO 7884-5 1987)《玻璃 粘度和粘度固定点 第5部分 沉棒粘度计测定工作点》.pdf
  • DIN ISO 7884-6-1998 Glass - Viscosity and viscometric fixed points - Part 6 Determination of softening point (ISO 7884-6 1987)《玻璃 粘度和粘度固定点 第6部分 软化点的测定》.pdf DIN ISO 7884-6-1998 Glass - Viscosity and viscometric fixed points - Part 6 Determination of softening point (ISO 7884-6 1987)《玻璃 粘度和粘度固定点 第6部分 软化点的测定》.pdf
  • DIN ISO 7884-7-1998 Glass - Viscosity and viscometric fixed points - Part 7 Determination of annealing point and strain point by beam bending (ISO 7884-7 1987)《玻璃 粘度和粘度固定点 第7部分 射线束.pdf DIN ISO 7884-7-1998 Glass - Viscosity and viscometric fixed points - Part 7 Determination of annealing point and strain point by beam bending (ISO 7884-7 1987)《玻璃 粘度和粘度固定点 第7部分 射线束.pdf
  • 相关搜索

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

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