【计算机类职业资格】三级信息管理技术机试-316及答案解析.doc

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

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

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

3、jsVal()void readDat ( )int i;FILE *fp;fP = fopen(“IN26.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(“OUT26.DAT“, “w“);fp

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

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

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

7、bi);printf (“/n“);writeDat ( );writeDat ( )FILE *fp;int i;fp = fopen(“OUT26.DAT“, “w“);fprintf(fp, “%dkn“, cnt);for(i = 0; icnt; i+)fprintf(fp, “%dkn“, bi);fclose(fp);(分数:100.00)_正确答案:(void jsVal()int i, thou, hun, ten, data, j;int ab, cd;for (i=0; i200; i+)thou=a i/1000; /*求千位数字*/hun=a i %1000/100;

8、 /*求百位数字*/ten=ai %100/10; /*求十位数字*/data=a i %10; /*求个位数字*/ab=10*thou+data; /*把千位数字和个位数字重新组成一个新的十位数*/cd=10*hun+ten; /*把百位数字和十位数字组成另一个新的十位数*/if (ab%2=1 /*则把满足条件的数存入数组 b 中*/for (i=0; icnt-1; i+) /*将数组 b 的数按从大到小的顺序排列*/for (j=i+1; jcnt; j+)if (bibj)data=b i;bi=bj;b j =data;)解析:解析 本题看起似乎比较繁琐,但只要仔细分析,把思路理清

9、还是不难解决的。由题意可以列出解题步骤如下:(1)求得当前所取得的整数的千位、百位、十位、个位上的数字值。可以借助“/”(除法)与“%”(取余)两个运算符。“thou=ai/1000:hun=ai%1000/100;ten=ai%10010;data=ai%10;”这 4 条语句可以依次取得原 4 位数的千位、百位、十位及个位上的数字值。(2)按照要求(第一个十位数:新十位数的十位数字是原 4 位数的千位数字,新十位数的个位数字是原 4 位数的个位数;第二个十位数:新十位数的十位数字是原 4 位数的百位数字,新十位数的个位数字是原 4 位数的十位数字)把求得的各个位上的数字值组成两个新的十位数 ab 和 cd,用“ab=10*thou+data;cd=10*hun+ten;”语句实现。(3)对新组成的两个十位数进行条件判断(判断条件的语句是“if(ab%2=1&cd%2=1&(ab%5=0|cd%5=0)& ab!=0&cd!=0)”)。如果满足条件,则把原来的 4 位数放到数组 b 中,同时用一个计数器变量 cnt 求出满足条件的 4 位数的个数。(4)对数组 b 中的 4 位数用选择法进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 300130-6-2000 Integrated Services Digital Network (ISDN) - Malicious Call Identification (MCID) supplementary service - Digital Subscriber Signalling System No one (DSS1) pr.pdf DIN EN 300130-6-2000 Integrated Services Digital Network (ISDN) - Malicious Call Identification (MCID) supplementary service - Digital Subscriber Signalling System No one (DSS1) pr.pdf
  • DIN EN 300132-2-2017 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 2 Operated by -48 V direct curren.pdf DIN EN 300132-2-2017 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 2 Operated by -48 V direct curren.pdf
  • DIN EN 300132-3-0-2013 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 3 Operated by rectified current.pdf DIN EN 300132-3-0-2013 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 3 Operated by rectified current.pdf
  • DIN EN 300132-3-1-2013 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 3 Operated by rectified current.pdf DIN EN 300132-3-1-2013 Environmental Engineering (EE) - Power supply interface at the input to telecommunications and datacom (ICT) equipment - Part 3 Operated by rectified current.pdf
  • DIN EN 300132-3-2005 Environmental Engineering (EE) - Power supply interface at the input to telecommunications equipment - Part 3 Operated by rectified current source alternating .pdf DIN EN 300132-3-2005 Environmental Engineering (EE) - Power supply interface at the input to telecommunications equipment - Part 3 Operated by rectified current source alternating .pdf
  • DIN EN 300135-1-2008 Electromagnetic compatibility and Radio spectrum Matters (ERM) - Land Mobile Service - Citizens- Band (CB) radio equipment - Angle-modulated Citizens- Band rad.pdf DIN EN 300135-1-2008 Electromagnetic compatibility and Radio spectrum Matters (ERM) - Land Mobile Service - Citizens- Band (CB) radio equipment - Angle-modulated Citizens- Band rad.pdf
  • DIN EN 300135-2-2008 Electromagnetic compatibility and Radio spectrum Matters (ERM) - Land Mobile Service - Citizens- Band (CB) radio equipment - Angle-modulated Citizens- Band rad.pdf DIN EN 300135-2-2008 Electromagnetic compatibility and Radio spectrum Matters (ERM) - Land Mobile Service - Citizens- Band (CB) radio equipment - Angle-modulated Citizens- Band rad.pdf
  • DIN EN 300138-1-2000 Integrated Services Digital Network (ISDN) - Closed User Group (CUG) supplementary service Digital Subscriber Signalling System No one (DSS1) protocol - Part 1.pdf DIN EN 300138-1-2000 Integrated Services Digital Network (ISDN) - Closed User Group (CUG) supplementary service Digital Subscriber Signalling System No one (DSS1) protocol - Part 1.pdf
  • DIN EN 300138-2-2000 Integrated Services Digital Network (ISDN) - Closed User Group (CUG) supplementary service - Digital Subscriber Signalling System No one (DSS1) protocol - Part.pdf DIN EN 300138-2-2000 Integrated Services Digital Network (ISDN) - Closed User Group (CUG) supplementary service - Digital Subscriber Signalling System No one (DSS1) protocol - Part.pdf
  • 相关搜索

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

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