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

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

1、国家三级(网络技术)机试模拟试卷 33及答案与解析 一、程序设计题 1 在文件 in33.dat中有 200个正整数,且每个正整数均在 100至 9999之间。函数readDat()的功能是读取这 200个数并存放到数组 aa中。请编制函数 jsSort(),该函数的功能是:要求按照每个数的后 3位的大小进行升序排列,将排序后的前 10个数存入数组 bb中,如果数组比中出现后 3位相等的数,则对这些数按原始 4位数据进行降序排列。最后调用函数 writeDat()把结果比输出到文件 out33 dat中。 例如:处理前 6012 5099 9012 7025 8088 处理后 9012 601

2、2 7025 8088 5099 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat)和写函数 writeDat()的内容。 试题程序: #include 9include #include int aa200,bb10; void readDat(); void writeDat(); void jsSort() void main() readDat(); jsSort(); writeDat(); void readDat () FILE *in; int i; in=fopen (“ in33. dat“, “r“ ); for(i=0;i200;i+) f

3、scanf (in,“%d “, fclose (in); void writeDat() FILE *out; int i; clrscr (); out=fopen ( “out33. dat“, “w“ ); for (i=0;i10; i+) printf (“i=%d, %dn“, i+l,bb i ); fprintf (out, “%dn“, bb i ); fclose (out); 国家三级(网络技术)机试模拟试卷 33答案与解析 一、程序设计题 1 【正确答案】 void jsSort() int i, j, data; for (i=O; i 199; i+) for (

4、j=i+l; j 200; j+) if (aa ii %1000 aa j %1000) /*按照每个数的后 3位的大小进行升序排例 */ data=aa i; aaii=aaj; aa j =data; elseif(aai%lOOO=aaj%1000) /*如果后 3位数值相等 ,则对这些数值 按原始 4位数据进行降序 */ if (aa Ii aa j ) data=aa Iii; aaii=aaj; aa j =data; for (i=O; i10; i+) /*将排好序的前十个数存入数组 bb中 */ bbi=aai; 【试题解析】 本题考查的知识点如下: (1)循环结构的嵌套。

5、 (2)选择结构的嵌套 。 (3)特殊运算符 “%” 的使用。 (4)数据的升降序排列。 在该题中,首先要解决的问题是如何把题中 4位数转换成符合要求的 3位数。这里要用到一个比较特殊的运算符 %,它的功能是取余。将 4位数除以 1000取余则得到要求的 3位数。根据题意,若后 3位相等,则按照原数据进行降序排序,所以在这里要加一个选择结构进行判断。对数据进行排序,可以使用最简单的 “选择排序法 ”。即第一次从第一个数据开始和所有后面的数据进行比较,与比它大 (小 )的数据交换位置,将数据中最大 (小 )的数交换到最前面。第二次从第二个数据开 始与后面的数据进行比较,将此次比较中最 (小 )的数据交换至第二个位置,直至最后一个数据。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 6059-501-2009 Aerospace series Electrical cables installation Protection sleeves Test methods Part 501 Voltage proof test Edition P 1《航空航天系列.安装电缆.保护套.测试方法.第501部分 电压验证测试..pdf AECMA PREN 6059-501-2009 Aerospace series Electrical cables installation Protection sleeves Test methods Part 501 Voltage proof test Edition P 1《航空航天系列.安装电缆.保护套.测试方法.第501部分 电压验证测试..pdf
  • AECMA PREN 6059-502-2009 Aerospace series Electrical cables installation Protection sleeves Test methods Part 502 Resistance to electrical arcs Edition P 1《航空航天系列.安装电缆.保护套.测试方法.第50.pdf AECMA PREN 6059-502-2009 Aerospace series Electrical cables installation Protection sleeves Test methods Part 502 Resistance to electrical arcs Edition P 1《航空航天系列.安装电缆.保护套.测试方法.第50.pdf
  • AECMA PREN 6060-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of the Tensile Single Lap Shear Strength Edition P1《航空航天系列.纤维加固塑料试验方法拉伸单切变长度.P1版》.pdf AECMA PREN 6060-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of the Tensile Single Lap Shear Strength Edition P1《航空航天系列.纤维加固塑料试验方法拉伸单切变长度.P1版》.pdf
  • AECMA PREN 6061-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Sandwich Flexural Strength 4 Point Bending Edition P1《航空航天系列.纤维加固塑料试验方法扰曲强度4点弯曲.P1版》.pdf AECMA PREN 6061-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Sandwich Flexural Strength 4 Point Bending Edition P1《航空航天系列.纤维加固塑料试验方法扰曲强度4点弯曲.P1版》.pdf
  • AECMA PREN 6062-1995 Aerospace Series Fibre Reinforced Plastics Test Method Flatwise Tensile Test of Composite Sandwich Panel Edition P1《航空航天系列.纤维加固塑料试验方法平面拉伸测试混合物面板.P1版》.pdf AECMA PREN 6062-1995 Aerospace Series Fibre Reinforced Plastics Test Method Flatwise Tensile Test of Composite Sandwich Panel Edition P1《航空航天系列.纤维加固塑料试验方法平面拉伸测试混合物面板.P1版》.pdf
  • AECMA PREN 6063-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Material Degradation Due to Chemical Products Edition P1《航空航天系列.纤维加固塑料试验方法由于化学物质退化.P1版》.pdf AECMA PREN 6063-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Material Degradation Due to Chemical Products Edition P1《航空航天系列.纤维加固塑料试验方法由于化学物质退化.P1版》.pdf
  • AECMA PREN 6064-1995 Aerospace Series Non-Metallic Materials Analysis of Non-Metallic Materials (Cured) for the Determination of the Extent of Cure by Differential Scanning Calorim.pdf AECMA PREN 6064-1995 Aerospace Series Non-Metallic Materials Analysis of Non-Metallic Materials (Cured) for the Determination of the Extent of Cure by Differential Scanning Calorim.pdf
  • AECMA PREN 6066-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Tensile Strength of a Tapered and Stepped Joints Edition P1《航空航天系列.纤维加固塑料测试放大拉伸强度锥形接口.P.pdf AECMA PREN 6066-1995 Aerospace Series Fibre Reinforced Plastics Test Method Determination of Tensile Strength of a Tapered and Stepped Joints Edition P1《航空航天系列.纤维加固塑料测试放大拉伸强度锥形接口.P.pdf
  • AECMA PREN 6067-2000 Aerospace Series Pin Quick Release Self-Retaining Positive Locking Double Acting Button Handle Edition P 2《航空航天系列.栓快速释放自我保护阳极锁双钮扣手柄.P2版》.pdf AECMA PREN 6067-2000 Aerospace Series Pin Quick Release Self-Retaining Positive Locking Double Acting Button Handle Edition P 2《航空航天系列.栓快速释放自我保护阳极锁双钮扣手柄.P2版》.pdf
  • 相关搜索

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

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