【计算机类职业资格】计算机三级(数据库技术)上机考试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 变量得到的是个位上的数字。

展开阅读全文
相关资源
猜你喜欢
  • EN 12735-2-2010 0625 Copper and copper alloys - Seamless round copper tubes for air conditioning and refrigeration - Part 2 Tubes for equipment《铜和铜合金 空气调节和制冷用无缝圆形铜管 第2部分 设备用管》.pdf EN 12735-2-2010 0625 Copper and copper alloys - Seamless round copper tubes for air conditioning and refrigeration - Part 2 Tubes for equipment《铜和铜合金 空气调节和制冷用无缝圆形铜管 第2部分 设备用管》.pdf
  • EN 12735-2-2016 en Copper and copper alloys - Seamless round tubes for air conditioning and refrigeration - Part 2 Tubes for equipment《铜和铜合金空气调节和制冷的无缝管-第2部分 设备用管》.pdf EN 12735-2-2016 en Copper and copper alloys - Seamless round tubes for air conditioning and refrigeration - Part 2 Tubes for equipment《铜和铜合金空气调节和制冷的无缝管-第2部分 设备用管》.pdf
  • EN 12736-2001 en Electrically propelled road vehicles - Airborne acoustical noise of vehicle during charging with on-board chargers - Determination of sound power level《动道路车辆 用车载充电.pdf EN 12736-2001 en Electrically propelled road vehicles - Airborne acoustical noise of vehicle during charging with on-board chargers - Determination of sound power level《动道路车辆 用车载充电.pdf
  • EN 12737-2004 en Precast concrete products - Floor slats for livestock (Incorporates Amendment A1 2007)《预制混凝土产品 家畜用地板横木 包含修改件A1-10 2007》.pdf EN 12737-2004 en Precast concrete products - Floor slats for livestock (Incorporates Amendment A1 2007)《预制混凝土产品 家畜用地板横木 包含修改件A1-10 2007》.pdf
  • EN 12738-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Containment of Animals inoculated with Microorganisms in Experiments《生物技术 研究 开发和分.pdf EN 12738-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Containment of Animals inoculated with Microorganisms in Experiments《生物技术 研究 开发和分.pdf
  • EN 1274-2004 en Thermal Spraying - Powders - Composition Technical Supply Conditions《热喷涂 粉末 成分 交货技术条件》.pdf EN 1274-2004 en Thermal Spraying - Powders - Composition Technical Supply Conditions《热喷涂 粉末 成分 交货技术条件》.pdf
  • EN 12740-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Handling Inactivating and Testing of Waste《生物技术 研究 开发和分析实验室 废弃物的运输 减除活性和试验指南》.pdf EN 12740-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Handling Inactivating and Testing of Waste《生物技术 研究 开发和分析实验室 废弃物的运输 减除活性和试验指南》.pdf
  • EN 12741-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Biotechnology Laboratory Operations《生物技术 研究 开发与分析用实验室 生物技术实验室操作指南》.pdf EN 12741-1999 en Biotechnology - Laboratories for Research Development and Analysis - Guidance for Biotechnology Laboratory Operations《生物技术 研究 开发与分析用实验室 生物技术实验室操作指南》.pdf
  • EN 12742-1999 en Fruit and Vegetable Juices - Determination of the Free Amino Acids Content - Liquid Chromatographic Method《水果和蔬菜汁 自由氨基酸含量的测定 液相色谱法》.pdf EN 12742-1999 en Fruit and Vegetable Juices - Determination of the Free Amino Acids Content - Liquid Chromatographic Method《水果和蔬菜汁 自由氨基酸含量的测定 液相色谱法》.pdf
  • 相关搜索
    资源标签

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

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