[计算机类试卷]国家三级(网络技术)机试模拟试卷44及答案与解析.doc

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

1、国家三级(网络技术)机试模拟试卷 44及答案与解析 一、程序设计题 1 已知数据文件 IN44.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 isValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的数的个数 cnt,再把所有满足此条件的 4位数依次存入数组 b中,然后对数组 b的 4位数按从小到大的顺序进行排序,最后调用写函数 writeDat()把数组 b中的数输出到 OUT44.DAT文件中。 例如: 9123, 9-1-2-3 0,则该数满足条件,存入数组 b中,且个数 cnt=cnt+1。

2、9812, 9-8-1-2 0,则该数不满足条件,忽略。 注意:部分源程序已给出。 程序中已定义数组: a300, b300,己定义变量: cnt。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio.h int a300,b300,cnt=0; jsValue() main () iht i; readDat(); jsValue(); writeDat(); for(i=0;i cnt;i+) printf(“b%d=%dn“,i,bi); readDat() FILE *fp; int i; fp=fo

3、pen(“IN44.DAT“,“r“); printf ( “cnt=%dn“, cnt); for (i=0;i 300; i+) fscanf (fp, “%d, “, fclose (fp); writeDat () FILE *fp; int i; fp=fopen ( “OUT44. DAT“ , “w“ ); fprintf (fp, “%aln“, cnt); for (i=0; i cnt;i+) fprintf(fp, “%dn“,bi); fclose (fp); 国家三级(网络技术)机试模拟试卷 44答案与解析 一、程序设计题 1 【正确答案】 jsValue ( ) i

4、nt i, thou, hun, ten, data, j; for (i=O; i 300; i+) thou=a i/1000; /*求四位数的千位数字 */ hun=a i%1000/100; /*求四位数的百位数字 */ ten=a i%100/10; /*求四位数的十位数字 */ data=a i %10; /*求四位数的个位数字 * / if (thou-hun-ten-data O) /*如果千位数减百位数减十位数减个位数大于零 */ bcut =a i; /*则把该数存入数组 b中 */ cut+; /*统计满足条件的数的个数 */ for (i=O; i cnt-1; i+)

5、 /*对数组 b的 4位数按从小到大的顺序进行排序 */ for (j=i+l; j cnt; j+) if (bi bj) data=b Ii; bi-bj; b j =data; 【试题解析】 本题考查的知识点如下: (1)运算符 “%” 及 “/”的使用。 (2)循环结构及选择结构的使用。 在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特 殊运算符号 “%” ( 取余 )和 “/” (整除 )。将一个 4位数整除 1000则可得到其千位上的数字,除以 1000取余再整除 100则可得百位上的数字,除以 100取余再整除 10则可得十位上的数字,除以 10取余则得个位上的数字。然后按照题意要求将各位依次相减进行判断。最后的排序采用 “选择排序法 ”。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3841-511-2003 Aerospace Series Circuit Breakers Test Methods Part 511 Combined Test Temperature Altitude and Vibration Edition P 3《航空航天系列.断路器试验方法.第511部分 综合试验 温度、高度和振动》.pdf AECMA PREN 3841-511-2003 Aerospace Series Circuit Breakers Test Methods Part 511 Combined Test Temperature Altitude and Vibration Edition P 3《航空航天系列.断路器试验方法.第511部分 综合试验 温度、高度和振动》.pdf
  • AECMA PREN 3842-1996 Aerospace Series Circular Tube for Fluids in Corrosion Resistant Steel Diameter 3 2 mm Less Than or Equal to D Less Than or Equal to 100 mm Thickness 0 32 mm L.pdf AECMA PREN 3842-1996 Aerospace Series Circular Tube for Fluids in Corrosion Resistant Steel Diameter 3 2 mm Less Than or Equal to D Less Than or Equal to 100 mm Thickness 0 32 mm L.pdf
  • AECMA PREN 3843-1999 Aerospace Series Nuts Bihexagonal Self-Locking with Counterbore in Heat Resisting Steel Passivated Classification 1 100 MPa (at Ambient Temperature) 650 Degree.pdf AECMA PREN 3843-1999 Aerospace Series Nuts Bihexagonal Self-Locking with Counterbore in Heat Resisting Steel Passivated Classification 1 100 MPa (at Ambient Temperature) 650 Degree.pdf
  • AECMA PREN 3844-1-1995 Aerospace Series Flammability of Non Metallic Materials Part 1  Small Burner Test Vertical Determination of the Vertical Flame Propagation Edition P 1《航空航天系列.pdf AECMA PREN 3844-1-1995 Aerospace Series Flammability of Non Metallic Materials Part 1 Small Burner Test Vertical Determination of the Vertical Flame Propagation Edition P 1《航空航天系列.pdf
  • AECMA PREN 3844-2-1995 Aerospace Series Flammability of Non Metallic Materials Part 2  Small Burner Test Horizontal Determination of the Horizontal Flame Propagation Edition P 1《航空.pdf AECMA PREN 3844-2-1995 Aerospace Series Flammability of Non Metallic Materials Part 2 Small Burner Test Horizontal Determination of the Horizontal Flame Propagation Edition P 1《航空.pdf
  • AECMA PREN 3844-3-1995 Aerospace Series Flammability of Nom Metallic Materials Part 3  Small Burner Test 45 Degrees Determination of the Resistance of Material to Flame and Glow Pr.pdf AECMA PREN 3844-3-1995 Aerospace Series Flammability of Nom Metallic Materials Part 3 Small Burner Test 45 Degrees Determination of the Resistance of Material to Flame and Glow Pr.pdf
  • AECMA PREN 3845-2009 Aerospace series Rings retaining radial mounting in corrosion resisting steel passivated Edition P 1《航空航天系列.钝化耐腐蚀钢径向安装固定环.版本P1》.pdf AECMA PREN 3845-2009 Aerospace series Rings retaining radial mounting in corrosion resisting steel passivated Edition P 1《航空航天系列.钝化耐腐蚀钢径向安装固定环.版本P1》.pdf
  • AECMA PREN 3847-1997 Aerospace Series Paints and Varnishes Determination of the Sedimentation Rating Edition P 2《航空航天系列.色漆和清漆 沉淀值的测定》.pdf AECMA PREN 3847-1997 Aerospace Series Paints and Varnishes Determination of the Sedimentation Rating Edition P 2《航空航天系列.色漆和清漆 沉淀值的测定》.pdf
  • AECMA PREN 3848-1996 Aerospace Series Semi-Finished Metallic Products Methods of Measuring from Deviations Edition P2《航空航天系列半成品金属产品背离测量》.pdf AECMA PREN 3848-1996 Aerospace Series Semi-Finished Metallic Products Methods of Measuring from Deviations Edition P2《航空航天系列半成品金属产品背离测量》.pdf
  • 相关搜索

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

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