【计算机类职业资格】三级数据库技术机试-206及答案解析.doc

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

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

2、调用函数 WriteDat()把结果输出到文件 OUT5.DAT中。注意:部分源程序已给出。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。【试题程序】#include stdio.h#include memory.h#include string.h#include conio.h#include stdlib.h#define MAX 100typedef structchar dm5; /*产品代码*/char mc11; /*产品名称*/int dj; /*单价*/int sl; /*数量*/long je; /*金额*/PRO;

3、PRO sellMAX;void ReadDat();void WriteDat();void SortDat()void main()memset(sell,O,sizeof(sell);ReadDat();SortDat();WriteDat();void ReadDat()FILE *fp;char str80,ch11;int i;fp=fopen(“IN5.DAT“,“r“);for(i=0; i100; i+)fgets(str,80,fp);memcpy(sell11.dm,str,4);memcpy(sell11.mc,str+4,10);memcpy(ch,str+14,4)

4、ch4=0;selli.dj=atoi(ch);memcpy (ch,str+18,5);ch5=0;selli.sl=atoi(ch);selli.je=(long)selli.dj*selli.sl;fclose(fp);void WriteDat(void)FILE *fp;int i;fp=fopen(“OUT5.DAT“,“w“);for(i=0;i100;i+)fprintf(fp,“%s %s %4d %5d %101dkn“,selli.dm,selli.mc,selli.dj,selli.sl, selli.je);fclose(fp);(分数:100.00)_三级数据库技

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

6、iteDat()把结果输出到文件 OUT5.DAT中。注意:部分源程序已给出。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。【试题程序】#include stdio.h#include memory.h#include string.h#include conio.h#include stdlib.h#define MAX 100typedef structchar dm5; /*产品代码*/char mc11; /*产品名称*/int dj; /*单价*/int sl; /*数量*/long je; /*金额*/PRO;PRO sel

7、lMAX;void ReadDat();void WriteDat();void SortDat()void main()memset(sell,O,sizeof(sell);ReadDat();SortDat();WriteDat();void ReadDat()FILE *fp;char str80,ch11;int i;fp=fopen(“IN5.DAT“,“r“);for(i=0; i100; i+)fgets(str,80,fp);memcpy(sell11.dm,str,4);memcpy(sell11.mc,str+4,10);memcpy(ch,str+14,4);ch4=0;

8、selli.dj=atoi(ch);memcpy (ch,str+18,5);ch5=0;selli.sl=atoi(ch);selli.je=(long)selli.dj*selli.sl;fclose(fp);void WriteDat(void)FILE *fp;int i;fp=fopen(“OUT5.DAT“,“w“);for(i=0;i100;i+)fprintf(fp,“%s %s %4d %5d %101dkn“,selli.dm,selli.mc,selli.dj,selli.sl, selli.je);fclose(fp);(分数:100.00)_正确答案:(参考答案voi

9、d SortDat()int i,j;PRO xy;for(i=O;iMAX-1;i+)for(j=i+l;jMAX;j+)if(selli.jesellj.je) /*按金额从大到小进行排列*/ xy=selli;sellii=sellj;sellj=xy;else if(selli.je=sellj.je) /*若金额相同*/if(strcmp(selli.dm,sellj.dm)0) /*则按代码从小到大进行排列*/ xy=selli;selli=sellj;sellj=xy;)解析:解析 此题按金额从大到小进行排列,若金额相等,则按产品代码从小到大进行排列,相应语句为:if(selli.jesellj.je)(selli.je=sellj.je)&(strcmp(selli.dm,sellj.dm)O)

展开阅读全文
相关资源
猜你喜欢
  • GOST R IEC 60666-2013 Mineral insulating oils Detection and determination of specified additives《矿物绝缘油 指定添加剂的检测和测定》.pdf GOST R IEC 60666-2013 Mineral insulating oils Detection and determination of specified additives《矿物绝缘油 指定添加剂的检测和测定》.pdf
  • GOST R IEC 60695-1-1-2003 Fire hazard testing Part 1-1 Guidance for assessing the fire hazard of electrotechnical products General guidelines《火灾危险测试 第1-1部分 电子技术产品火灾评定指南 一般指导》.pdf GOST R IEC 60695-1-1-2003 Fire hazard testing Part 1-1 Guidance for assessing the fire hazard of electrotechnical products General guidelines《火灾危险测试 第1-1部分 电子技术产品火灾评定指南 一般指导》.pdf
  • GOST R IEC 60695-2-10-2011 Fire hazard testing Part 2-10 Glowing hot-wire based test methods Glow-wire apparatus and common test procedures《火灾危险测试 第2-10部分 灼热丝测试方法 灼热丝装置和一般检测规程》.pdf GOST R IEC 60695-2-10-2011 Fire hazard testing Part 2-10 Glowing hot-wire based test methods Glow-wire apparatus and common test procedures《火灾危险测试 第2-10部分 灼热丝测试方法 灼热丝装置和一般检测规程》.pdf
  • GOST R IEC 60695-2-2-2011 Fire hazard testing Part 2 Test methods Section 2 Needle-flame test《火灾危险测试 第2部分 检测方法 第2节 针焰测试》.pdf GOST R IEC 60695-2-2-2011 Fire hazard testing Part 2 Test methods Section 2 Needle-flame test《火灾危险测试 第2部分 检测方法 第2节 针焰测试》.pdf
  • GOST R IEC 60705-2011 Household microwave ovens Methods for measuring performance《家用微波炉 性能测量方法》.pdf GOST R IEC 60705-2011 Household microwave ovens Methods for measuring performance《家用微波炉 性能测量方法》.pdf
  • GOST R IEC 60711-2001 Occluded-ear simulator Technical requirements and test methods《封闭式耳朵模拟器 技术要求和试验方法》.pdf GOST R IEC 60711-2001 Occluded-ear simulator Technical requirements and test methods《封闭式耳朵模拟器 技术要求和试验方法》.pdf
  • GOST R IEC 60715-2003 Low-voltage switchgear and controlgear Mounting on rails for mechanical support of electrical devices in switchgear and controlgear installations《低压开关设备和控制设备 .pdf GOST R IEC 60715-2003 Low-voltage switchgear and controlgear Mounting on rails for mechanical support of electrical devices in switchgear and controlgear installations《低压开关设备和控制设备 .pdf
  • GOST R IEC 60719-1999 Calculation of the lower and upper limits for the average outer dimensions of cables with circular coper conductors and of rated voltages up to and including .pdf GOST R IEC 60719-1999 Calculation of the lower and upper limits for the average outer dimensions of cables with circular coper conductors and of rated voltages up to and including .pdf
  • GOST R IEC 60731-2001 Medical electrical equipment Dosimeters with ionization chambers in radiotherapy《医疗电气设备 放射线疗法中电离室的剂量计》.pdf GOST R IEC 60731-2001 Medical electrical equipment Dosimeters with ionization chambers in radiotherapy《医疗电气设备 放射线疗法中电离室的剂量计》.pdf
  • 相关搜索

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

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