[计算机类试卷]国家三级(数据库技术)机试模拟试卷109及答案与解析.doc

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

1、国家三级(数据库技术)机试模拟试卷 109及答案与解析 一、程序设计题 1 已知在文件 IN6.DAT中存有 100个产品销售记录,每个产品销售记录由产品代码 dm(字符型 4位 );产品名称 mc(字符型 10位 )、单价 dj(整型 )、数量 sl(整型 )、金额 je(长整型 )五部分组成。其中:金额 =单价 数量。函数 ReadDat()的功能是读取这 100个销售记录并存入结构数组 sell中。请编制函数 SortDat(),其功能要求:按产品代码从小到大进行排列,若产品代码相同,则按金额从小到大进行排列,最终排列结果仍存入结构 数组 sell中,最后调用函数 WilteDat()把

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

3、RO; 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=fbpen(“IN6.DAT“,“r“); for(i=0;i 100;i+) fgets(str,80,fp); memcpy(selli.dm,str,4); memcpy(selli.mc,str+4,10); m

4、emcpy(ch,str+14,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(“OUT6.DAT“,“w“); for(i=0;i 100;i+) fprintf(fp,“%s %s %4d %5d %101dn“, selli.dm, selli.mc,selli.dj,selli.sl, selli.je)

5、 fclose(fp); 国家三级(数据库技术)机试模拟试卷 109答案与解析 一、程序设计题 1 【正确答案】 void SortDat() int i,j; PRO xy; for(i=0;i MAX-1;i+) for(j=i+l;j MAX;j+) if(strcmp(selli.dm,sellj.dm) 0) /*按代码从小到大进行排列 */ xy=selli;selli=sellj;sellj=xy; else if(strcmp(selli.dm,sellj.dm)=O) /*若金额相同 */ if(selli.je sellj.je) /*则按代码从大到小进行排列 */ xy=selli;selli=sellj;sellj=xy; 【试题解析】 此题按产品代码从小到大进行排列,若产品代码相同,则按金额从小到大进行排列,相应语句为: if(strcmp(selli.dm,sellj.dm 0)(strcmp(selli.dm,sellj.dm=0&(selli.jesellj.je

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 2706-1985 Aerospace Series Aluminium Alloy 7009-T736510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain C.pdf ASD-STAN PREN 2706-1985 Aerospace Series Aluminium Alloy 7009-T736510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 125 mm with Peripheral Coarse Grain C.pdf
  • ASD-STAN PREN 2708-1985 Aerospace Series Aluminium Alloy 7075-T73510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 100 mm with Peripheral Coarse Grain Co.pdf ASD-STAN PREN 2708-1985 Aerospace Series Aluminium Alloy 7075-T73510 Bar and Section 1 2 Less Than or Equal to (a or D) Less Than or Equal to 100 mm with Peripheral Coarse Grain Co.pdf
  • ASD-STAN PREN 2709-1985 Aerospace Series Aluminium Alloy 2024-T3510 Bar and Section 1 2 Less Than or Equal to (a or D) less Than or Equal to 150 mm with Peripheral Coarse Grain Con.pdf ASD-STAN PREN 2709-1985 Aerospace Series Aluminium Alloy 2024-T3510 Bar and Section 1 2 Less Than or Equal to (a or D) less Than or Equal to 150 mm with Peripheral Coarse Grain Con.pdf
  • ASD-STAN PREN 2712-002-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 002 Scr.pdf ASD-STAN PREN 2712-002-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 002 Scr.pdf
  • ASD-STAN PREN 2712-003-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 003 Scr.pdf ASD-STAN PREN 2712-003-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 003 Scr.pdf
  • ASD-STAN PREN 2712-004-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 004 Scr.pdf ASD-STAN PREN 2712-004-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 004 Scr.pdf
  • ASD-STAN PREN 2712-005-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 005 Scr.pdf ASD-STAN PREN 2712-005-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 005 Scr.pdf
  • ASD-STAN PREN 2712-006-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 006 Scr.pdf ASD-STAN PREN 2712-006-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures between - 55 Degrees C and 150 Degrees C Part 006 Scr.pdf
  • ASD-STAN PREN 2712-007-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures Between - 55 Degrees C and 150 Degrees C Part 007 Scr.pdf ASD-STAN PREN 2712-007-1995 Aerospace Series Cables Electrical Single and Multicore for General Purpose Operating Temperatures Between - 55 Degrees C and 150 Degrees C Part 007 Scr.pdf
  • 相关搜索

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

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