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

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

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

2、则将满足此条件的四位数按从大到小的顺序存人数组 b 中,并要计算满足上述条件的四位数的个数 cnt。最后:main()函数调用写函数 writeDat()把结果 cnt 以及数组 b 中符合条件的四位数输出到 OUT.DAT 文件中。注意:部分源程序存在文件 PROG1.C 文件中。程序中已定义数组:a200,b200,已定义变量:cnt。请勿改动数据文件 IN.DAT 中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#indude #define MAX 200int aMAX,bMAX,cnt=0;void writeDat();

3、int isprime(int m)int i;for(i=2;im/2;i+)if(m%i=0) return 0;return 1;void jsVal()void readDat()int i;FILE *fp;fp=fopen(“in.dat“, “r“);for(i=0;iMAX;i+)fscanf(fp,“%d”fclose(fp);void main()int i;readDat();jsVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;j+) printf(“%d“,bi);printf(“/n”);writeDat();void wri

4、teDat()FILE *fp;int i;fp=fopen(“out.dat”,“w”);fprintf(fp,“%d/n”,cnt);for(i=0;icnt;i+)fprintf(fp,“%d/n“,bi);fclose(fp);(分数:100.00)_三级网络技术机试-213 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知数据文件 IN.DAT 中存有 200 个四位数,并已调用读函数 readDat()把这些数存入数组 a 中,请考生编制一个函数 jsVal(),其功能是:把千位数字和十位数字重新组成一个新的含有两位数字的数(

5、新数的十位数字是原四位数的千位数字,新数的个位数字是原四位数的十位数字),以及把个位数字和百位数字组成另一个新的含有两位数字的数(新数的十位数字是原四位数的个位数字,新数的个位数字是原四位数的百位数字),如果两个新组成的数均是素数且新数的十位数字均不为 0,则将满足此条件的四位数按从大到小的顺序存人数组 b 中,并要计算满足上述条件的四位数的个数 cnt。最后:main()函数调用写函数 writeDat()把结果 cnt 以及数组 b 中符合条件的四位数输出到 OUT.DAT 文件中。注意:部分源程序存在文件 PROG1.C 文件中。程序中已定义数组:a200,b200,已定义变量:cnt。

6、请勿改动数据文件 IN.DAT 中的任何数据、主函数 main()、读函数 readDat()和写函数 writeDat()的内容。试题程序#indude #define MAX 200int aMAX,bMAX,cnt=0;void writeDat();int isprime(int m)int i;for(i=2;im/2;i+)if(m%i=0) return 0;return 1;void jsVal()void readDat()int i;FILE *fp;fp=fopen(“in.dat“, “r“);for(i=0;iMAX;i+)fscanf(fp,“%d”fclose(f

7、p);void main()int i;readDat();jsVal();printf(“满足条件的数=%d/n“,cnt);for(i=0;icnt;j+) printf(“%d“,bi);printf(“/n”);writeDat();void writeDat()FILE *fp;int i;fp=fopen(“out.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; /*定义变量*/int a1

8、a2,a3,a4;int ab,cd;int temp;for(i=0;iMAX;i+)a1=ai%10; /*数位分解*/a2=ai%100/10;a3=ai%1000/100;a4=ai/1000;ab=a4*10+a2; /*数位重组*/cd=a1*10+a3;if(isprime(ab)for(i=0;icnt-1;i+) /*选择法排序*/for(1=i+1;jcnt;j+)if(bibj)temp=bi;bi=bi;bj=temp;)解析:解析 本题要求先将已知数按十进制位拆分并重新成两个两位数后,先按照一定的判断条件筛选统计,再按大小进行排序。依据题意,应依次从数组 a 中取出每一个四位数,按十进制位拆分并重组后,根据题目中给出的判断条件(两个新组成的数均是素数且新数的十位数字均不为 0,即 isprime(ab)&isprime(cd)&a4!=0&a1!=0)筛选后,将符合条件的四位数存入数组 b 中,同时计数器变量 cnt 加 1,最后将数组 b 中的四位数用选择法进行排序。注意:本题源代码中给出了求素数的 isprime()函数,可以直接调用该函数判断数是否是素数。

展开阅读全文
相关资源
猜你喜欢
  • EN 1802-2002 en Transportable Gas Cylinders - Periodic Inspection and Testing of Seamless Aluminium Alloy Gas Cylinders《可运输储气瓶 无缝铝合金储气瓶的周期性检验和测试》.pdf EN 1802-2002 en Transportable Gas Cylinders - Periodic Inspection and Testing of Seamless Aluminium Alloy Gas Cylinders《可运输储气瓶 无缝铝合金储气瓶的周期性检验和测试》.pdf
  • EN 1803-2002 en Transportable Gas Cylinders - Periodic Inspection and Testing of Welded Carbon Steel Gas Cylinders《可运输储气瓶 焊接炭素钢储气瓶的周期性检验和测试》.pdf EN 1803-2002 en Transportable Gas Cylinders - Periodic Inspection and Testing of Welded Carbon Steel Gas Cylinders《可运输储气瓶 焊接炭素钢储气瓶的周期性检验和测试》.pdf
  • EN 1804-1-2001 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 1 Support units and general requirements (Incorporates Amendment A.pdf EN 1804-1-2001 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 1 Support units and general requirements (Incorporates Amendment A.pdf
  • EN 1804-2-2001 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 2 Power set legs and rams (Incorporates Amendment A1 2010)《地下采矿机械 .pdf EN 1804-2-2001 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 2 Power set legs and rams (Incorporates Amendment A1 2010)《地下采矿机械 .pdf
  • EN 1804-3-2006 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 3 Hydraulic control systems (Incorporates Amendment A1 2010)《煤矿机械 .pdf EN 1804-3-2006 en Machines for underground mines - Safety requirements for hydraulic powered roof supports - Part 3 Hydraulic control systems (Incorporates Amendment A1 2010)《煤矿机械 .pdf
  • EN 1806-2006 en Chimneys - Clay ceramic flue blocks for single wall chimneys - Requirements and test methods《烟囱 单壁烟囱用粘土 陶瓷烟道砖 要求和试验方法-2000》.pdf EN 1806-2006 en Chimneys - Clay ceramic flue blocks for single wall chimneys - Requirements and test methods《烟囱 单壁烟囱用粘土 陶瓷烟道砖 要求和试验方法-2000》.pdf
  • EN 1807-1-2013 en Safety of woodworking machines - Band sawing machines - Part 1 Table band saws and band re-saws《木工机械安全性 带锯机械 第1部分 台式带锯机和再分带锯机》.pdf EN 1807-1-2013 en Safety of woodworking machines - Band sawing machines - Part 1 Table band saws and band re-saws《木工机械安全性 带锯机械 第1部分 台式带锯机和再分带锯机》.pdf
  • EN 1807-2-2013 en Safety of woodworking machines - Band sawing machines - Part 2 Log sawing machines《木工机械安全性 带锯机械 第2部分 锯木机》.pdf EN 1807-2-2013 en Safety of woodworking machines - Band sawing machines - Part 2 Log sawing machines《木工机械安全性 带锯机械 第2部分 锯木机》.pdf
  • EN 1808-2015 en Safety requirements for suspended access equipment - Design calculations stability criteria construction - Examinations and tests《暂停访问设备的安全要求 设计计算 稳定性标准 施工 检查和试验》.pdf EN 1808-2015 en Safety requirements for suspended access equipment - Design calculations stability criteria construction - Examinations and tests《暂停访问设备的安全要求 设计计算 稳定性标准 施工 检查和试验》.pdf
  • 相关搜索

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

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