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

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

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

2、组 sell 中,最后调用函数 WriteDat()把结果输出到文件 OUT6.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 writeDat()的内容。试题程序:#includestdio.h#includemem.h#includestring.h#includeconio.h#includestdlib.h#define MAX 100typedef structchar dm5;/*产品代码*/char mc11;/*产品名称*/int dj;/*单价*/int sl;/*数量*/long je;/*金额*/PRO;PR

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

4、lli.dj=atoi(ch);memcpy(ch,str+18,5);oh5=0;selli.sl=atoi(ch);selli.je=(;ong)selli.dj*selli.sl;fclose(fp);void WriteDat(void)FILE*fp;int i;fp=fopen(“OUT6.DAT“,“w“);for(i=0;i100;i+)printf(“%s%s%4d%5d%5d/n“,selli.dm,selli.mc,selli.dj,selli.sl,selli.je);fprintf(fp,“%s%s%4d%5d%5d/n“,selli.am,selli.mc,sell

5、i.dj,selli.sl,selli.je);fclose(fp);(分数:100.00)_三级数据库技术机试-89 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN.DAT 中存有 100 个产品销售记录,每个产品销售记录由产品代码 dm(字符型 4 位),产品名称 mc(字符型 10 位),单价 dj(整型),数量 sl(整型),金额 je(长整型)五部分组成。其中,“金额一单价*数量”计算得出。函数 ReadDat()是读取这 100 个销售记录并存入结构数组 sell 中。请编制函数SortDat(),其功能要求:按

6、产品代码从大到小进行排列,若产品代码相同,则按金额从大到小进行排列,最终排列结果仍存入结构数组 sell 中,最后调用函数 WriteDat()把结果输出到文件 OUT6.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 writeDat()的内容。试题程序:#includestdio.h#includemem.h#includestring.h#includeconio.h#includestdlib.h#define MAX 100typedef structchar dm5;/*产品代码*/char mc11;/*产品名称*/

7、int dj;/*单价*/int sl;/*数量*/long je;/*金额*/PRO;PRO sellMAX;void ReadDat();void WriteDat();void SortDat()void main()memset(sell,0,sizeof(sell);ReadDat();SortDat();WriteDat();void ReadDat()FILE*fp:char str80,ch11;int i;fp=fopen(“IN.DAT“,“r“);for(i=0;i100;i+)fgets(str,80,fp);memcpy(selli.dm,str,4);memcpy(

8、sellimc,str+4,10);memcpy(ch,str+14,4);ch4=0;selli.dj=atoi(ch);memcpy(ch,str+18,5);oh5=0;selli.sl=atoi(ch);selli.je=(;ong)selli.dj*selli.sl;fclose(fp);void WriteDat(void)FILE*fp;int i;fp=fopen(“OUT6.DAT“,“w“);for(i=0;i100;i+)printf(“%s%s%4d%5d%5d/n“,selli.dm,selli.mc,selli.dj,selli.sl,selli.je);fprin

9、tf(fp,“%s%s%4d%5d%5d/n“,selli.am,selli.mc,selli.dj,selli.sl,selli.je);fclose(fp);(分数:100.00)_正确答案:(void SortDat()int i,j;PRO xy;for(i=0;i99;i+)for(j=i+1;j100;j+)if(strcmp(selli.dm,sellj.dm)0/如果产品 i 的产品代码小于产品 j 的产品代码| strcmp(selli.dm,sellj.dm)=0/如果产品 i 的产品代码等于产品 j 的产品代码selli.jesellj.je) /如果产品 i 的金额小于产品 j 的金额xy=selli;sell i=sellj;sellj=xy;/产品 i 和产品 j 交换)解析:解析 本题主要考查数组的排序操作。算法思路 1、i 结点与后面的所有 j 结点比较,若符合条件则交换 i、j 结点位置。2、然后后移 i 结点,执行步骤 1 直到 i 结点是倒数第二结点为止。

展开阅读全文
相关资源
猜你喜欢
  • DIN 10776-2-2016 Analysis of coffee and coffee products - Determination of pH and acid content - Part 2 Method for soluble coffee《咖啡和咖啡制品的分析 pH值和酸度的测定 第2部分 可溶咖啡的测定方法》.pdf DIN 10776-2-2016 Analysis of coffee and coffee products - Determination of pH and acid content - Part 2 Method for soluble coffee《咖啡和咖啡制品的分析 pH值和酸度的测定 第2部分 可溶咖啡的测定方法》.pdf
  • DIN 10779-2011 Analysis of coffee and coffee products - Determination of 16-O-methyl cafestol content of roasted coffee - HPLC-method《咖啡和咖啡制品的分析 焙烘后的咖啡中16-0-甲基咖啡雌醇含量的测定 -HPLC法》.pdf DIN 10779-2011 Analysis of coffee and coffee products - Determination of 16-O-methyl cafestol content of roasted coffee - HPLC-method《咖啡和咖啡制品的分析 焙烘后的咖啡中16-0-甲基咖啡雌醇含量的测定 -HPLC法》.pdf
  • DIN 10780-2003 Instant coffee - Determination of free and total carbohydrate contents - Method using high-performance anion-exchange chromatography《速溶咖啡 游离和总碳化物含量测定 高效阴离子交换色谱法》.pdf DIN 10780-2003 Instant coffee - Determination of free and total carbohydrate contents - Method using high-performance anion-exchange chromatography《速溶咖啡 游离和总碳化物含量测定 高效阴离子交换色谱法》.pdf
  • DIN 10781-2000 Roasted ground coffee - Determination of loss in mass at 103 C (Routine method for the determination of moisture content)《炒研磨咖啡 103℃时质量损失测定(水分测定常规方法)》.pdf DIN 10781-2000 Roasted ground coffee - Determination of loss in mass at 103 C (Routine method for the determination of moisture content)《炒研磨咖啡 103℃时质量损失测定(水分测定常规方法)》.pdf
  • DIN 10783-2011 Analysis of coffee and coffee products - Determination of dichlormethane in decaffeinated green coffee using headspace gaschromatography《咖啡和咖啡制品的分析 采用顶空气相色谱法测定无咖啡因的生.pdf DIN 10783-2011 Analysis of coffee and coffee products - Determination of dichlormethane in decaffeinated green coffee using headspace gaschromatography《咖啡和咖啡制品的分析 采用顶空气相色谱法测定无咖啡因的生.pdf
  • DIN 10785-2013 en 1164 Analysis of coffee and coffee products - Determination of acrylamide - Methods using HPLC-MS MS and GC-MS after derivatization《咖啡和咖啡制品的分析 丙烯酰胺的测定 衍生化后高效液相色谱-.pdf DIN 10785-2013 en 1164 Analysis of coffee and coffee products - Determination of acrylamide - Methods using HPLC-MS MS and GC-MS after derivatization《咖啡和咖啡制品的分析 丙烯酰胺的测定 衍生化后高效液相色谱-.pdf
  • DIN 10792-2013 Analysis of coffee and coffee products - Preparation of coffee beverage for analytical purposes《咖啡和咖啡制品的分析 分析用咖啡饮料的制备》.pdf DIN 10792-2013 Analysis of coffee and coffee products - Preparation of coffee beverage for analytical purposes《咖啡和咖啡制品的分析 分析用咖啡饮料的制备》.pdf
  • DIN 108-1-1988 Slide projectors and slides projector slides for general use and for theatre projection nominal sizes dimensions of masks picture position and marking《幻灯放映机和幻灯片 普通幻灯.pdf DIN 108-1-1988 Slide projectors and slides projector slides for general use and for theatre projection nominal sizes dimensions of masks picture position and marking《幻灯放映机和幻灯片 普通幻灯.pdf
  • DIN 108-10-1977 Slide projectors and slides projection lenses for overhead projectors optical data《幻灯放映机和幻灯片 空架放映机用放映镜头 光学参数》.pdf DIN 108-10-1977 Slide projectors and slides projection lenses for overhead projectors optical data《幻灯放映机和幻灯片 空架放映机用放映镜头 光学参数》.pdf
  • 相关搜索

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

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