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

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

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

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

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

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

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 4378-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Solution Treated and Precipitation Treated Wire for Rivets D Less Than or Equal to 1 6 mm Ed.pdf AECMA PREN 4378-1997 Aerospace Series Heat Resisting Alloy NI-PH2601 (NiCr19Fe19Nb5Mo3) Solution Treated and Precipitation Treated Wire for Rivets D Less Than or Equal to 1 6 mm Ed.pdf
  • AECMA PREN 4379-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Forging De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(NiCr22Mo9.pdf AECMA PREN 4379-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Forging De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(NiCr22Mo9.pdf
  • AECMA PREN 4380-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Bar and Section De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(N.pdf AECMA PREN 4380-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Bar and Section De Less Than or Equal to 200 mm Edition P 1《航空系列 抗热合金NI-PH3601(N.pdf
  • AECMA PREN 4381-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Structural Application D Less Than or Equal to 50 mm a Less T.pdf AECMA PREN 4381-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Structural Application D Less Than or Equal to 50 mm a Less T.pdf
  • AECMA PREN 4382-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Hydraulic Application D Less Than or Equal to 50 mm a Less Th.pdf AECMA PREN 4382-1997 Aerospace Series Heat Resisting Alloy NI-PH3601 (NiCr22Mo9Nb) Solution Treated Seamless Tubes for Hydraulic Application D Less Than or Equal to 50 mm a Less Th.pdf
  • AECMA PREN 4383-1997 Aerospace Series Heat Resisting Alloy NI-CH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔.P1.pdf AECMA PREN 4383-1997 Aerospace Series Heat Resisting Alloy NI-CH2601 (NiCr19Fe19Nb5Mo3) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔.P1.pdf
  • AECMA PREN 4384-1997 Aerospace Series Heat Resisting Alloy NI-CH1303 (NiCo20Cr20Mo5Ti2Al) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔..pdf AECMA PREN 4384-1997 Aerospace Series Heat Resisting Alloy NI-CH1303 (NiCo20Cr20Mo5Ti2Al) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.抗热合金NI-CH2601(NiCr19Fe19Nb5Mo3)非热处理重熔..pdf
  • AECMA PREN 4385-2001 Aerospace Series Non-Metallic Materials General Organisation of Standardisation Links between Types of Standards Edition P 2《航空航天系列.非金属物质一般结构标准类型标准.P2版》.pdf AECMA PREN 4385-2001 Aerospace Series Non-Metallic Materials General Organisation of Standardisation Links between Types of Standards Edition P 2《航空航天系列.非金属物质一般结构标准类型标准.P2版》.pdf
  • AECMA PREN 4386-2001 Aerospace Series Non-Metallic Materials Rules for the Drafting and Presentation of Test Method Standards Edition P 2 Replaced by TR 4386《航空航天系列.非金属物质规则提案和展示试验方.pdf AECMA PREN 4386-2001 Aerospace Series Non-Metallic Materials Rules for the Drafting and Presentation of Test Method Standards Edition P 2 Replaced by TR 4386《航空航天系列.非金属物质规则提案和展示试验方.pdf
  • 相关搜索

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

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