[计算机类试卷]国家三级(数据库技术)机试模拟试卷89及答案与解析.doc

上传人:吴艺期 文档编号:495367 上传时间:2018-11-28 格式:DOC 页数:4 大小:27KB
下载 相关 举报
[计算机类试卷]国家三级(数据库技术)机试模拟试卷89及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷89及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷89及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷89及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(数据库技术)机试模拟试卷 89及答案与解析 一、程序设计题 1 已知数据文件 IN89.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制一函数 jsVal(),其功能是:如果一个 4位数的千位数字上的值加个位数字上的值恰好等于百位数字上的值加上十位数字上的值,并且此 4位数是奇数,则统计出满足此条件的数的个数 cnt并把这些 4位数按从小到大的顺序存入数组 b中,最后调用写函数 writeDat()把结果 cnt以及数组 b中符合条件的 4位数输出到 OUT89 DAT文件中 。 注意:部分源程序已给出。 程序中己定义数组: a200,

2、 b200,已定义变量: cnt。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio.h #define MAX 200 int aMAX,bMAX,cnt=0; void jsVal( ) void readDat( ) int i; FILE *fp; fp=fopen(“IN89.DAT“,“r“); for(i=0;i MAX;i+) fscanf(fp,“%d“, fclosefp); main() int i; readDat(); jsVal(); printf ( “满足条件的数 =%dn“

3、 cnt); for(i=0;i cnt;i+) printf(“%d“,bi); printf(“n“); writeDat(); writeDat() FILE *fp; int i; fp=fopen(“OUT89.DAT“,“w“); fprintf(fp,“%dn“,cnt); for(i=0;i cnt;i+) fprintf(fp, “%dn“,bi); fclose(fp); 国家三级(数据库技术)机试模拟试卷 89答案与解析 一、程序设计题 1 【正确答案】 void jsVal( ) int i, thou, hun, ten, data, j; for(i=0; i 2

4、00; i+) thou=i%1000/100; /*求四位数的首位数字 */ ten=i%100/10; /*求四位数的十位数字 */ data=ai%10; /*求四位数的个位数字 */ if(thou+data=hun+ten)&ai%2=1) /*如果千位数加个位数等于百位数加十位数,并且此数是奇数 */ bcnt=ai; /*则将满足条件的数存入数组 b中 */ cnt+; /*统计满足条件的数的个数 */ for(i=0; i cnt-1; i+) /*将数组 b中的数按从小到大的顺序排列 */ for(j=i+1; i cnt; j+) if(bi bi) data=bi; bi=bj); bj=data; 【试题解析】 本题考查的知识点如下: (1)运算符 “%” 及 “/”的使用。 (2)选择结构中多个条件的布尔运算。 (3)数据的排序。 在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号 “%”( 取余 )和 “/”(整除 ),拆分方法略。一个数除以 2取余所得的数为 1,则这个数是奇数。题中给出的两个条件必须同时满足,所以两条件之间用 “与 ”运算。将符合条件的数先存入数组 b中,再对 b中的数据进行排序。排序使用 “选择排序法 ”。

展开阅读全文
相关资源
猜你喜欢
  • ANSI UL 1241-2003 UL Standard for Safety Junction Boxes for Swimming Pool Luminaires (Seventh Edition Reprint with Revisions through and Including August 28 2013).pdf ANSI UL 1241-2003 UL Standard for Safety Junction Boxes for Swimming Pool Luminaires (Seventh Edition Reprint with Revisions through and Including August 28 2013).pdf
  • ANSI UL 1242-2006 UL Standard for Safety Electrical Intermediate Metal Conduit C Steel (Fourth Edition Reprint with Revisions Through and Including June 25 2018)《电子过渡金属导管.钢》.pdf ANSI UL 1242-2006 UL Standard for Safety Electrical Intermediate Metal Conduit C Steel (Fourth Edition Reprint with Revisions Through and Including June 25 2018)《电子过渡金属导管.钢》.pdf
  • ANSI UL 1242-2014 UL Standard for Safety Electrical Intermediate Metal Conduit - Steel (Fourth Edition Reprint with revisions through and including March 5 2014).pdf ANSI UL 1242-2014 UL Standard for Safety Electrical Intermediate Metal Conduit - Steel (Fourth Edition Reprint with revisions through and including March 5 2014).pdf
  • ANSI UL 1247-2007 UL Standard for Safety Diesel Engines for Driving Stationary Fire Pumps (Fifth Edition Reprint with revisions through and including August 5 2014)《离心消防泵驱动用柴油发动机的安.pdf ANSI UL 1247-2007 UL Standard for Safety Diesel Engines for Driving Stationary Fire Pumps (Fifth Edition Reprint with revisions through and including August 5 2014)《离心消防泵驱动用柴油发动机的安.pdf
  • ANSI UL 125-2014 UL Standard for Safety Flow Control Valves for Anhydrous Ammonia and LP-Gas (Ninth Edition Reprint with revisions through and including January 12 2018).pdf ANSI UL 125-2014 UL Standard for Safety Flow Control Valves for Anhydrous Ammonia and LP-Gas (Ninth Edition Reprint with revisions through and including January 12 2018).pdf
  • ANSI UL 1254-2013 UL Standard for Safety Pre-Engineered Dry Chemical Extinguishing System Units (Fourth Edition Reprint with Revisions Through and Including September 7 2017)《采用预制件.pdf ANSI UL 1254-2013 UL Standard for Safety Pre-Engineered Dry Chemical Extinguishing System Units (Fourth Edition Reprint with Revisions Through and Including September 7 2017)《采用预制件.pdf
  • ANSI UL 1256-2002 UL Standard for Safety Fire Test of Roof Deck Constructions (Fourth Edition Reprint with Revisions Through and Including July 17 2013)《屋顶覆盖层结构的着火试验》.pdf ANSI UL 1256-2002 UL Standard for Safety Fire Test of Roof Deck Constructions (Fourth Edition Reprint with Revisions Through and Including July 17 2013)《屋顶覆盖层结构的着火试验》.pdf
  • ANSI UL 1261-2016 UL Standard for Safety Electric Water Heaters for Pools and Tubs (Sixth Edition Reprint with revisions through and including September 1 2017).pdf ANSI UL 1261-2016 UL Standard for Safety Electric Water Heaters for Pools and Tubs (Sixth Edition Reprint with revisions through and including September 1 2017).pdf
  • ANSI UL 127-2011 UL Standard for Safety Factory-Built Fireplaces (Ninth Edition Reprint with revisions through and including July 27 2016)《工厂生产壁炉的安全标准》.pdf ANSI UL 127-2011 UL Standard for Safety Factory-Built Fireplaces (Ninth Edition Reprint with revisions through and including July 27 2016)《工厂生产壁炉的安全标准》.pdf
  • 相关搜索

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

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