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

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

1、三级网络技术机试-107 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN44.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 isValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的数的个数 cnt,再把所有满足此条件的 4位数依次存入数组 b中,然后对数组 b的 4位数按从小到大的顺序进行排序,最后调用写函数 writeDat()把数组 b中的数输出到 OUT44.DAT文件中。例如:9123,9-1-2-30,则该数满足条件

2、存入数组 b中,且个数 cnt=cnt+1。9812,9-8-1-20,则该数不满足条件,忽略。注意:部分源程序已给出。程序中已定义数组:a300,b300,己定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#includestdio.hint a300,b300,cnt=0;jsValue()main ()iht i;readDat();jsValue();writeDat();for(i=0;icnt;i+)printf(“b%d=%d/n“,i,bi);readDat()FILE *fp;int i;fp=fop

3、en(“IN44.DAT“,“r“);printf ( “cnt=%d/n“, cnt);for (i=0;i300; i+)fscanf (fp, “%d, “, fclose (fp);writeDat ()FILE *fp;int i;fp=fopen ( “OUT44. DAT“ , “w“ );fprintf (fp, “%al/n“, cnt);for (i=0; icnt;i+)fprintf(fp, “%d/n“,bi);fclose (fp);(分数:100.00)_三级网络技术机试-107 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:1

4、00.00)1.已知数据文件 IN44.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 isValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的数的个数 cnt,再把所有满足此条件的 4位数依次存入数组 b中,然后对数组 b的 4位数按从小到大的顺序进行排序,最后调用写函数 writeDat()把数组 b中的数输出到 OUT44.DAT文件中。例如:9123,9-1-2-30,则该数满足条件,存入数组 b中,且个数 cnt=cnt+1。9812,9-8-1-20,则该数不满足条件,忽略。注意:部分源程

5、序已给出。程序中已定义数组:a300,b300,己定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序:#includestdio.hint a300,b300,cnt=0;jsValue()main ()iht i;readDat();jsValue();writeDat();for(i=0;icnt;i+)printf(“b%d=%d/n“,i,bi);readDat()FILE *fp;int i;fp=fopen(“IN44.DAT“,“r“);printf ( “cnt=%d/n“, cnt);for (i=0;i3

6、00; i+)fscanf (fp, “%d, “, fclose (fp);writeDat ()FILE *fp;int i;fp=fopen ( “OUT44. DAT“ , “w“ );fprintf (fp, “%al/n“, cnt);for (i=0; icnt;i+)fprintf(fp, “%d/n“,bi);fclose (fp);(分数:100.00)_正确答案:(jsValue ( )int i, thou, hun, ten, data, j;for (i=O; i300; i+)thou=a i/1000; /*求四位数的千位数字*/hun=a i%1000/100

7、 /*求四位数的百位数字*/ten=a i%100/10; /*求四位数的十位数字*/data=a i %10; /*求四位数的个位数字* /if (thou-hun-ten-dataO) /*如果千位数减百位数减十位数减个位数大于零*/bcut =a i; /*则把该数存入数组 b中*/cut+; /*统计满足条件的数的个数*/for (i=O; icnt-1; i+) /*对数组 b的 4位数按从小到大的顺序进行排序*/for (j=i+l; jcnt; j+)if (bibj)data=b Ii;bi-bj;b j =data;)解析:解析本题考查的知识点如下:(1)运算符“%”及“/”的使用。(2)循环结构及选择结构的使用。在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号“%” (取余)和“/” (整除)。将一个 4位数整除 1000则可得到其千位上的数字,除以 1000取余再整除 100则可得百位上的数字,除以 100取余再整除 10则可得十位上的数字,除以 10取余则得个位上的数字。然后按照题意要求将各位依次相减进行判断。最后的排序采用“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • BS EN 2002-1-2005 Aerospace series - Metallic materials - Test methods - Part 1 Tensile testing at ambient temperature《航天航空系列 金属材料 试验方法 第1部分 室温下拉伸试验》.pdf BS EN 2002-1-2005 Aerospace series - Metallic materials - Test methods - Part 1 Tensile testing at ambient temperature《航天航空系列 金属材料 试验方法 第1部分 室温下拉伸试验》.pdf
  • BS EN 2003-009-2007 Aerospace series - Test methods - Titanium and titanium alloys - Determination of surface contamination《航空航天系列 试验方法 钛和钛合金 表面污染测定》.pdf BS EN 2003-009-2007 Aerospace series - Test methods - Titanium and titanium alloys - Determination of surface contamination《航空航天系列 试验方法 钛和钛合金 表面污染测定》.pdf
  • BS EN 2003-010-2007 Aerospace series - Titanium and titanium alloys - Test methods - Sampling for determination of hydrogen content《航空航天系列 钛和钛合金 试验方法 抽样测定氢含量》.pdf BS EN 2003-010-2007 Aerospace series - Titanium and titanium alloys - Test methods - Sampling for determination of hydrogen content《航空航天系列 钛和钛合金 试验方法 抽样测定氢含量》.pdf
  • BS EN 2004-1-1993 Test methods for aluminium and aluminium alloy products - Determination of electrical conductivity of wrought aluminium alloys《铝和铝合金产品试验方法 第1部分 锻铝合金电导率的测定》.pdf BS EN 2004-1-1993 Test methods for aluminium and aluminium alloy products - Determination of electrical conductivity of wrought aluminium alloys《铝和铝合金产品试验方法 第1部分 锻铝合金电导率的测定》.pdf
  • BS EN 2004-5-1993 Test methods for aluminium and aluminium alloy products - Determination of cladding thickness and copper diffusion of clad semi-finished products《铝和铝合金产品试验方法 第5部分.pdf BS EN 2004-5-1993 Test methods for aluminium and aluminium alloy products - Determination of cladding thickness and copper diffusion of clad semi-finished products《铝和铝合金产品试验方法 第5部分.pdf
  • BS EN 2009-1992 Bearings - Airframe rolling rigid single row ball bearings in steel diameter series 8 and 9 Dimensions and loads《轴承 钢的8号和9号直径系列机体刚性单列球轴承、尺寸和负荷》.pdf BS EN 2009-1992 Bearings - Airframe rolling rigid single row ball bearings in steel diameter series 8 and 9 Dimensions and loads《轴承 钢的8号和9号直径系列机体刚性单列球轴承、尺寸和负荷》.pdf
  • BS EN 201-2009 Plastics and rubber machines - Injection moulding machines - Safety requirements《塑料盒橡胶机械 注射模制机械 安全要求》.pdf BS EN 201-2009 Plastics and rubber machines - Injection moulding machines - Safety requirements《塑料盒橡胶机械 注射模制机械 安全要求》.pdf
  • BS EN 2011-1989 Specification for bearings - airframe rolling rigid single row ball bearings in corrosion resisting steel diameter series 8 and 9 Dimensions and loads《轴承规范 耐蚀钢的8号和9.pdf BS EN 2011-1989 Specification for bearings - airframe rolling rigid single row ball bearings in corrosion resisting steel diameter series 8 and 9 Dimensions and loads《轴承规范 耐蚀钢的8号和9.pdf
  • BS EN 2012-1989 Specification for bearings - airframe rolling rigid single row ball bearings in steel diameter series 0 and 2 Dimensions and loads《轴承规范 钢的0号和2号直径系列机体刚性单列球轴承 尺寸和负荷》.pdf BS EN 2012-1989 Specification for bearings - airframe rolling rigid single row ball bearings in steel diameter series 0 and 2 Dimensions and loads《轴承规范 钢的0号和2号直径系列机体刚性单列球轴承 尺寸和负荷》.pdf
  • 相关搜索

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

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