【计算机类职业资格】计算机三级(数据库技术)上机考试13及答案解析.doc

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

1、计算机三级(数据库技术)上机考试 13 及答案解析(总分:-1.00,做题时间:90 分钟)1.下列程序的功能是:在 3 位整数(100 至 999)中寻找符合下面条件的整数,并依次从小到大存入数组b 中;它既是完全平方数,又有两位数字相同,例如 144,676 等。 请编制函数 int jsValue(int bb)实现此功能,满足该条件的整数的个数通过所编制的函数返回。 最后调用函数 writeDat()把结果输出到文件 OUT12.DAT 中。 注意:部分源程序已给出。 请勿改动主函数 main()和写函数 writeDat()的内容。 试题程序: #include int jsValu

2、e(int bb ) main() int b20, num; num = jsValue(b); writeDat(num, b); writeDat(int num, int b) FILE *out; int i; out = fopen(“OUT12.DAT“, “w“); fprintf(out, “%dn“, num); for(i = 0; i num; i+) fprintf(out, “%dn“, bi); fclose(out); (分数:-1.00)_计算机三级(数据库技术)上机考试 13 答案解析(总分:-1.00,做题时间:90 分钟)1.下列程序的功能是:在 3 位

3、整数(100 至 999)中寻找符合下面条件的整数,并依次从小到大存入数组b 中;它既是完全平方数,又有两位数字相同,例如 144,676 等。 请编制函数 int jsValue(int bb)实现此功能,满足该条件的整数的个数通过所编制的函数返回。 最后调用函数 writeDat()把结果输出到文件 OUT12.DAT 中。 注意:部分源程序已给出。 请勿改动主函数 main()和写函数 writeDat()的内容。 试题程序: #include int jsValue(int bb ) main() int b20, num; num = jsValue(b); writeDat(num

4、 b); writeDat(int num, int b) FILE *out; int i; out = fopen(“OUT12.DAT“, “w“); fprintf(out, “%dn“, num); for(i = 0; i num; i+) fprintf(out, “%dn“, bi); fclose(out); (分数:-1.00)_正确答案:(int jsValue(int bb ) int i,j,k=0; int hun,ten,data; for(i=100;i=999;i+) j=10; while(j*j=i) if (i=j*j) /*如果该数是完全平方数*/

5、hun=i/100; /*求该数的百位数字*/ data=i-hun*100; /*得到后两位数*/ ten=data/10; /*求该数的十位数字*/ data=data-ten*10; /*求该数的个位数字*/ if(hun=ten | hun=data | ten=data) /*有两位数字相同*/ bbk=i; /*则把该数存入数组 bb 中*/ k+; /*统计满足条件的数的个数*/ j+; return k; /*返回满足该条件的整数的个数*/ )解析:解答本题,首先应该考虑用一个 for 循环来依次取得 100 到 999 之间的各个数,并对当前所取得的数进行两个条件判断:一是判

6、断该数是否是完全平方数;二是判断该数是否有两位数字相同。如果以上两个条件同时满足,则把该数存放到 b 数组中,尽管题目要求所存的数必须从小到大,但我们取数的过程本身就是从小到大取得,因此,排序工作是没有必要做的,按照取数的顺序,把满足条件的数值存放到数组b 中就可以了。判断某个数是否是完全平方数的方法是看该数是否可以拆成完全相同的两个数的积(当然要拆成的两个数一定是两位数),因此,我们再利用一个循环用 10 以上的两位数逐个去拆被判断的数,如果被判断的数恰好可以被完全拆分,则第一个条件成立,接着就开始依次取得被判断的数的百位、十位、个位上的数字值,看是否有两位数字相同。取得每一位上的数字值可以用“hun=i/100;data=i-hun*100;ten=data/10;data=data-ten*10;”几条语句来实现,hun 变量得到的是百位上的数字,ten变量得到的是十位上的数字, data 变量得到的是个位上的数字。

展开阅读全文
相关资源
猜你喜欢
  • DIN 56950-3-2015 Entertainment technology - Machinery installations - Part 3 Safety requirements for stands and truss lifts of stands《娱乐技术 机械装置 第3部分 看台和看台桁架提升机的安全要求》.pdf DIN 56950-3-2015 Entertainment technology - Machinery installations - Part 3 Safety requirements for stands and truss lifts of stands《娱乐技术 机械装置 第3部分 看台和看台桁架提升机的安全要求》.pdf
  • DIN 56950-4-2015 Entertainment technology - Machinery installations - Part 4 Safety requirements for serially manufactured projection screens《娱乐技术 机械装置 第4部分 投影屏幕系列生产的安全要求》.pdf DIN 56950-4-2015 Entertainment technology - Machinery installations - Part 4 Safety requirements for serially manufactured projection screens《娱乐技术 机械装置 第4部分 投影屏幕系列生产的安全要求》.pdf
  • DIN 56955-2017 Entertainment technology - Load assumptions in stages and associated areas - Imposed loads《娱乐技术 舞台和相关区域的载荷能力 施加荷载》.pdf DIN 56955-2017 Entertainment technology - Load assumptions in stages and associated areas - Imposed loads《娱乐技术 舞台和相关区域的载荷能力 施加荷载》.pdf
  • DIN 5698-1-2014 Round steel link chains - Round steel link chains pitch 2 8d for chain strands in bucket elevators - Part 1 Grade 2 case hardened《圆钢环节链 斗式升降机中链环节距为2 8d的圆钢环节链 第1部分 2.pdf DIN 5698-1-2014 Round steel link chains - Round steel link chains pitch 2 8d for chain strands in bucket elevators - Part 1 Grade 2 case hardened《圆钢环节链 斗式升降机中链环节距为2 8d的圆钢环节链 第1部分 2.pdf
  • DIN 5699-1994 Chain U-links (shackles) for conveyors《传动带输送机用U型链节(U形钩环)》.pdf DIN 5699-1994 Chain U-links (shackles) for conveyors《传动带输送机用U型链节(U形钩环)》.pdf
  • DIN 571-2016 Hexagon head wood screws《六角头木螺钉》.pdf DIN 571-2016 Hexagon head wood screws《六角头木螺钉》.pdf
  • DIN 57131-1984 Construction and operation of electric fence equipment [VDE Specification]《电子栅栏设备的建造和使用(VDE 规范)》.pdf DIN 57131-1984 Construction and operation of electric fence equipment [VDE Specification]《电子栅栏设备的建造和使用(VDE 规范)》.pdf
  • DIN 57250-1-1981 Specifications for cables wires and flexible cords for power installations general《电力设备用电缆、导线和软线 总则》.pdf DIN 57250-1-1981 Specifications for cables wires and flexible cords for power installations general《电力设备用电缆、导线和软线 总则》.pdf
  • DIN 57250-106-1982 Cables wires and flexible cords for power installation ETFE single-core-non-sheated cables for internal wiring [VDE Specification]《电力设备用电缆、导线和软线 内部线路用ETFE单芯护套电缆(.pdf DIN 57250-106-1982 Cables wires and flexible cords for power installation ETFE single-core-non-sheated cables for internal wiring [VDE Specification]《电力设备用电缆、导线和软线 内部线路用ETFE单芯护套电缆(.pdf
  • 相关搜索
    资源标签

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

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