【计算机类职业资格】计算机三级(数据库技术)上机考试15及答案解析.doc

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

1、计算机三级(数据库技术)上机考试 15 及答案解析(总分:-1.00,做题时间:90 分钟)1.已知在文件 IN6.DAT 中存有 100 个产品销售记录,每个产品销售记录由产品代码 dm(字符型 4 位)、产品名称 mc(字符型 10 位)、单价 dj(整型)、数量 sl(整型)、金额 je(长整型)几部分组成。其中:金额=单价数量。函数 ReadDat()的功能是读取这 100 个销售记录并存入结构数组 sell 中。请编制函数 SortDat(),其功能要求:按产品名称从小到大进行排列,若产品名称相同,则按金额从小到大进行排列,最终排列结果仍存入结构数组 sell 中,最后调用函数 Wr

2、iteDat()把结果输出到文件 OUT6.DAT 中。注意:部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序: #include #include #include #include #include #define MAX 100 typedef struct char dm5; /*产品代码 */ char mc11;/* 产品名称 */ int dj; /* 单价 */ int sl; /* 数量 */ long je; /* 金额*/ PRO; PRO sell MAX; void ReadDat(); vo

3、id WriteDat(); void SortDat() main() memset(sell, 0, sizeof(sell); ReadDat(); SortDat(); WriteDat(); void ReadDat() FILE *fp; char str80, ch11; int i; fp = fopen(“IN6.DAT“, “r“); for (i = 0; i sellj.je) /*则按金额从小到大进行排列*/ xy=selli;selli=sellj;sellj=xy; )解析:本题是有关结构体数组的排序问题,可以用选择法来实现。用第一个元素的产品名称依次和它后面的元素的产品名称进行比较,如果发现当前元素的产品名称比后面的某个元素的产品名称对应字符的ASCII 码大(这里用到了字符串比较函数 strcmp()),则交换这两个元素的位置,继续和后面的其他元素进行比较,最终在第一个元素中存放的是产品名称最小的元素。以此类推,就实现了从小到大排序的功能。注意:这里要进行交换的是两个结构体变量,而不是它们的某一个域,因此,要借助第三个结构体变量来充当中间容器。若产品名称相同,则要按照金额从小到大进行排序。

展开阅读全文
相关资源
猜你喜欢
  • BS 3529-1962 Specification for dimensions of flywheel housing mounting pads and brackets for i c engines《内燃机用飞轮箱安装垫和托架的尺寸规范》.pdf BS 3529-1962 Specification for dimensions of flywheel housing mounting pads and brackets for i c engines《内燃机用飞轮箱安装垫和托架的尺寸规范》.pdf
  • BS 3531-11-1991 Implants for osteosynthesis - Implants for osteosynthesis - Specification for staples with parallel legs《骨结合术 外科植入物 第11部分 平行脚U形钉规范》.pdf BS 3531-11-1991 Implants for osteosynthesis - Implants for osteosynthesis - Specification for staples with parallel legs《骨结合术 外科植入物 第11部分 平行脚U形钉规范》.pdf
  • BS 3531-14 2-1990 Implants for osteosynthesis - Intramedullary nailing systems - Specification for medullary pins (Rush type) and introducer extractors《骨接合术用外科植入物 第14部分 骨髓腔内钉接物系列 第.pdf BS 3531-14 2-1990 Implants for osteosynthesis - Intramedullary nailing systems - Specification for medullary pins (Rush type) and introducer extractors《骨接合术用外科植入物 第14部分 骨髓腔内钉接物系列 第.pdf
  • BS 3531-15-1992 Implants for osteosynthesis - Specification for devices for the fixation of the ends of the femur in adults《骨结合术 外科植入物 第15部分 成人股骨端固定器件规范》.pdf BS 3531-15-1992 Implants for osteosynthesis - Specification for devices for the fixation of the ends of the femur in adults《骨结合术 外科植入物 第15部分 成人股骨端固定器件规范》.pdf
  • BS 3531-23 1-1991 Implants for osteosynthesis - Bone plates - Method for determination of bending strength and stiffness《接骨用植入物 骨板 弯曲强度和刚度的测定方法》.pdf BS 3531-23 1-1991 Implants for osteosynthesis - Bone plates - Method for determination of bending strength and stiffness《接骨用植入物 骨板 弯曲强度和刚度的测定方法》.pdf
  • BS 3531-23 2-1993 Implants for osteosynthesis - Bone plates - Specification for holes and slots for use with screws of 4 5 mm 4 2 mm 4 0 mm 3 9 mm 3 5 mm and 2 9 mm nominal sizes《接.pdf BS 3531-23 2-1993 Implants for osteosynthesis - Bone plates - Specification for holes and slots for use with screws of 4 5 mm 4 2 mm 4 0 mm 3 9 mm 3 5 mm and 2 9 mm nominal sizes《接.pdf
  • BS 3531-23 3-1991 Implants for osteosynthesis - Bone plates - Specification for holes corresponding to screws with asymmetrical thread and spherical undersurfaces《骨接合术用外科植入物 第23部分 .pdf BS 3531-23 3-1991 Implants for osteosynthesis - Bone plates - Specification for holes corresponding to screws with asymmetrical thread and spherical undersurfaces《骨接合术用外科植入物 第23部分 .pdf
  • BS 3531-5 1-1997 Implants for osteosynthesis - Bone screws and auxiliary equipment - Specification for keys for use with screws having heads with hexagon socket《骨接合术用外科植入物 第5部分 骨螺钉.pdf BS 3531-5 1-1997 Implants for osteosynthesis - Bone screws and auxiliary equipment - Specification for keys for use with screws having heads with hexagon socket《骨接合术用外科植入物 第5部分 骨螺钉.pdf
  • BS 3531-5 2-1990 Implants for osteosynthesis Bone screws and auxiliary equipment Specification for screwdrivers for screws having heads with single slot cruciate slot or cross-rece.pdf BS 3531-5 2-1990 Implants for osteosynthesis Bone screws and auxiliary equipment Specification for screwdrivers for screws having heads with single slot cruciate slot or cross-rece.pdf
  • 相关搜索
    资源标签

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

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