【计算机类职业资格】计算机三级(网络技术)上机考试16及答案解析.doc

上传人:feelhesitate105 文档编号:1337368 上传时间:2019-10-17 格式:DOC 页数:2 大小:27KB
下载 相关 举报
【计算机类职业资格】计算机三级(网络技术)上机考试16及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】计算机三级(网络技术)上机考试16及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、计算机三级(网络技术)上机考试 16 及答案解析(总分:-1.00,做题时间:90 分钟)1.在文件 IN3.DAT 中有 200 个正整数,且每个数均在 1000 至 9999 之间。函数 readDat()的功能是读取这200 个数存放到数组 aa 中。请编制函数 jsSort(),该函数的功能是:要求按每个数的后 3 位的大小进行降序排列,将排序后的前 10 个数存入数组 b 中,如果数组 b 中出现后 3 位相等的数,则对这些数按原始4 位数据进行升序排列。最后调用函数 writeDat()把结果 bb 输出到文件 OUT3.DAT 中。 例如:处理前 9012 5099 6012 7

2、025 8088 处理后 5099 8088 7025 6012 9012 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include #include #include int aa200, bb10; void jsSort() main() readDat(); jsSort(); writeDat(); readDat() FILE *in; int i; in = fopen(“IN3.DAT“, “r“); for(i = 0; i 200; i+) fscanf(in, “%d,“, fc

3、lose(in); writeDat() FILE *out; int i; out = fopen(“OUT3.DAT“, “w“); clrscr(); for (i = 0; i 10; i+) printf(“i=%d,%d/n“, i + 1, bbi); fprintf(out, “%d/n“, bbi); fclose(out); (分数:-1.00)_计算机三级(网络技术)上机考试 16 答案解析(总分:-1.00,做题时间:90 分钟)1.在文件 IN3.DAT 中有 200 个正整数,且每个数均在 1000 至 9999 之间。函数 readDat()的功能是读取这200

4、个数存放到数组 aa 中。请编制函数 jsSort(),该函数的功能是:要求按每个数的后 3 位的大小进行降序排列,将排序后的前 10 个数存入数组 b 中,如果数组 b 中出现后 3 位相等的数,则对这些数按原始4 位数据进行升序排列。最后调用函数 writeDat()把结果 bb 输出到文件 OUT3.DAT 中。 例如:处理前 9012 5099 6012 7025 8088 处理后 5099 8088 7025 6012 9012 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include #i

5、nclude #include int aa200, bb10; void jsSort() main() readDat(); jsSort(); writeDat(); readDat() FILE *in; int i; in = fopen(“IN3.DAT“, “r“); for(i = 0; i 200; i+) fscanf(in, “%d,“, fclose(in); writeDat() FILE *out; int i; out = fopen(“OUT3.DAT“, “w“); clrscr(); for (i = 0; i 10; i+) printf(“i=%d,%d

6、/n“, i + 1, bbi); fprintf(out, “%d/n“, bbi); fclose(out); (分数:-1.00)_正确答案:(void jsSort() int i,j,data; for(i=0;iaaj) /*则要按原 4 位数的值进行从小到大的排序*/ data=aai;aai=aaj;aaj=data; for(i=0;i解析:本题实质上考的是对数组元素进行排序的问题。最容易理解的方法是选择法。选择法的基本思想是:依次用当前取得的元素和它后面的其他元素进行比较,比如要从大到小进行排序,则只要发现后面的元素中有比当前元素大的,就把刚发现的较大的元素与当前元素交换,这样做的目的是当与其后的所有元素都比较完后,可以保证当前位置的当前元素存放着最大数。按照同样的方法去取得次大数。由于本题中题目要求要对数组中的 4 位数的后 3 位进行排序,因此,要首先取得各个数的后 3 位并做比较,“aai%1000”就可以得到每个数的后 3 位。根据题意,对这些数按后 3 位进行从大到小的排序。若后 3 位数相等,则要按原 4 位数的值进行从小到大的排序。

展开阅读全文
相关资源
猜你喜欢
  • GOST R ISO 10776-2014 Geotextiles and geotextile-related products Determination of water permeability characteristics normal to the plane under load《土工织物及其相关产品 平面在负载条件下正常水渗透特征的测定》.pdf GOST R ISO 10776-2014 Geotextiles and geotextile-related products Determination of water permeability characteristics normal to the plane under load《土工织物及其相关产品 平面在负载条件下正常水渗透特征的测定》.pdf
  • GOST R ISO 1081-1994 Drives using V- belts and qrooved pulleys Terms and definitions《V带或三角皮带轮驱动 术语和定义》.pdf GOST R ISO 1081-1994 Drives using V- belts and qrooved pulleys Terms and definitions《V带或三角皮带轮驱动 术语和定义》.pdf
  • GOST R ISO 10813-1-2011 Vibration Guidance for selection of vibration generating machines Part 1 Equipment for dynamic environmental testing《机械振动 振动发生设备选择指南 第1部分 动态环境试验设备》.pdf GOST R ISO 10813-1-2011 Vibration Guidance for selection of vibration generating machines Part 1 Equipment for dynamic environmental testing《机械振动 振动发生设备选择指南 第1部分 动态环境试验设备》.pdf
  • GOST R ISO 10816-3-1999 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Part 3 Industrial machines with nominal power above 15 kW and nom《机械.pdf GOST R ISO 10816-3-1999 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Part 3 Industrial machines with nominal power above 15 kW and nom《机械.pdf
  • GOST R ISO 10816-4-1999 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Part 4 Gas turbine driven sets《机械振动 在非转动部件上对机器震动测量结果的评估 第4部分 燃气涡轮.pdf GOST R ISO 10816-4-1999 Mechanical vibration Evaluation of machine vibration by measurements on non-rotating parts Part 4 Gas turbine driven sets《机械振动 在非转动部件上对机器震动测量结果的评估 第4部分 燃气涡轮.pdf
  • GOST R ISO 10817-1-1999 Mechanical vibration Rotating shaft vibration measuring systems Part 1 Relative and absolute sensing of radial vibration《机械振动 转轴振动测量系统 第1部分 径向振动的相对和绝对感应》.pdf GOST R ISO 10817-1-1999 Mechanical vibration Rotating shaft vibration measuring systems Part 1 Relative and absolute sensing of radial vibration《机械振动 转轴振动测量系统 第1部分 径向振动的相对和绝对感应》.pdf
  • GOST R ISO 10819-1999 Mechanical vibration and shock Method for the measurements and evaluation of the vibration transmissibility of gloves at the palm of the hand《机械振动和冲击 手套手掌部分振动.pdf GOST R ISO 10819-1999 Mechanical vibration and shock Method for the measurements and evaluation of the vibration transmissibility of gloves at the palm of the hand《机械振动和冲击 手套手掌部分振动.pdf
  • GOST R ISO 1082-1994 Mining Shackle type cennector units for chain conveyors《采矿 链式传送带钩环接合设备》.pdf GOST R ISO 1082-1994 Mining Shackle type cennector units for chain conveyors《采矿 链式传送带钩环接合设备》.pdf
  • GOST R ISO 10848-1-2012 Acoustics Laboratory measurement of the flanking transmission of airborne and impact sound between adjoining rooms Part 1 Basic provisions《声学 邻室间空气载声和冲击声的侧向.pdf GOST R ISO 10848-1-2012 Acoustics Laboratory measurement of the flanking transmission of airborne and impact sound between adjoining rooms Part 1 Basic provisions《声学 邻室间空气载声和冲击声的侧向.pdf
  • 相关搜索

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

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