【计算机类职业资格】三级信息管理技术机试-139及答案解析.doc

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

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

2、数组 sell 中,最后调用函数 WriteDat()把结果输出到文件 OUT61.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio. h# inc ludemem, h#includestring. h# inc ludeconio, h#inc ludestdl ib. h#define MAX 100typedef structchar dm5;char mcll;int dj;int sl;long je;PRO;PRO sell MAX;void ReadDat (

3、);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(“IN61.DAT“, “r“);for (i=0; i100; i+)fgets (str, 80, fp);memcpy (sell i .dm, str, 4);memcpy (sell i .mc, str+4,10);memcpy (ch, str+

4、14, 4);ch4 =0;sell i .dj=atoi (ch);memcpy (ch, str+18,5);ch5 =0;sell i . sl=atoi (ch);selli . je= (long) sell i .dj*selli.sl;fclose (fp);void WriteDat ()FILE *fp;int i;fp=fopen ( “OUT61. DAT“, “w“ );for (i=0; i100; i+)fprintf(fp,“%s %s %4d %5d %101d/n“,sellsell i.dj,selli.sl, selli.je);fclose (fp);(

5、分数:100.00)_三级信息管理技术机试-139 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN61.DAT 中存有 100 个产品销售记录,每个产品销售记录由产品代码 dm(字符型 4 位)、产品名称 mc(字符型 10 位)、单价 dj(整型)、数量 s1(整型)、金额 je(长整型)几部分组成。其中,金额=单价数量可计算得出。函数 ReadDat()的功能是读取这 100 个销售记录并存入数组 sell 中。请编制函数SortDat(),其功能要求:按金额从小到大进行排列,若金额相同,则按产品代码从大到小进行排列,最

6、终排列结果仍存入结构数组 sell 中,最后调用函数 WriteDat()把结果输出到文件 OUT61.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio. h# inc ludemem, h#includestring. h# inc ludeconio, h#inc ludestdl ib. h#define MAX 100typedef structchar dm5;char mcll;int dj;int sl;long je;PRO;PRO sell MAX;void

7、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(“IN61.DAT“, “r“);for (i=0; i100; i+)fgets (str, 80, fp);memcpy (sell i .dm, str, 4);memcpy (sell i .mc, str+4,10);memcpy

8、 (ch, str+14, 4);ch4 =0;sell i .dj=atoi (ch);memcpy (ch, str+18,5);ch5 =0;sell i . sl=atoi (ch);selli . je= (long) sell i .dj*selli.sl;fclose (fp);void WriteDat ()FILE *fp;int i;fp=fopen ( “OUT61. DAT“, “w“ );for (i=0; i100; i+)fprintf(fp,“%s %s %4d %5d %101d/n“,sellsell i.dj,selli.sl, selli.je);fcl

9、ose (fp);(分数:100.00)_正确答案:(void SortDat ()int i,j;PRO xy;for (i=0; i99; i+)for(j=i+l; j100; j+)if (sell i . jesell j . je) /*按金额从小到大进行排列*/xy=sell i;sell i =sell j;sell j =xy;else if (selli.je=sellj.je) /*若金额相同*/if (strcmp (sell i .dm, sell j .dm) 0) /*则按产品代码从大到小时行排列*/xy=sell i;sell i =sell j;sell j =xy;)解析:解析 本题考查的知识点如下:(1)结构体及结构数组的相关操作。(2)结构数组的排序。(3)字符型数组的比较。本题着重考查结构体变量的访问、赋值,包括结构体本身及结构体中各个成员的访问和赋值。根据题目要求,我们首先要按照金额对记录从小到大进行排列。若金额相同,则要比较产品代码。因为产品代码为字符型,所以不能使用简单的比较运算符进行比较。在这里,我们使用了字符串处理函数strcmp(char*strl1,char*strl2,unsigned int cout)对其进行比较。因为已定义了结构数组,就可以使用循环进行比较排序。排序采用前面介绍的“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 16125-2016 LPG Equipment and Accessories - Pipework systems and supports - LPG liquid phase and vapour pressure phase German version EN 16125 2015《液化石油气设备和配件 管道系统和支持 液化石油气液相.pdf DIN EN 16125-2016 LPG Equipment and Accessories - Pipework systems and supports - LPG liquid phase and vapour pressure phase German version EN 16125 2015《液化石油气设备和配件 管道系统和支持 液化石油气液相.pdf
  • DIN EN 16128-2016 Ophthalmic optics - Reference method for the testing of spectacle frames and sunglasses for nickel release German version EN 16128 2015《眼科光学 镜框和镜片部分释放的镍含量测试的参考方法 .pdf DIN EN 16128-2016 Ophthalmic optics - Reference method for the testing of spectacle frames and sunglasses for nickel release German version EN 16128 2015《眼科光学 镜框和镜片部分释放的镍含量测试的参考方法 .pdf
  • DIN EN 16129-2013 Pressure regulators automatic change-over devices having a maximum regulated pressure of 4 bar with a maximum capacity of 150kg h associated safety devices and ad.pdf DIN EN 16129-2013 Pressure regulators automatic change-over devices having a maximum regulated pressure of 4 bar with a maximum capacity of 150kg h associated safety devices and ad.pdf
  • DIN EN 16135-2012 Automotive fuels - Determination of manganese content in unleaded petrol - Flame atomic absorption spectrometric method (FAAS) German version EN 16135 2011《汽车燃料 在.pdf DIN EN 16135-2012 Automotive fuels - Determination of manganese content in unleaded petrol - Flame atomic absorption spectrometric method (FAAS) German version EN 16135 2011《汽车燃料 在.pdf
  • DIN EN 16136-2015 Automotive fuels - Determination of manganese and iron content in unleaded petrol - Inductively coupled plasma optical emission spectrometry (ICP OES) method Germ.pdf DIN EN 16136-2015 Automotive fuels - Determination of manganese and iron content in unleaded petrol - Inductively coupled plasma optical emission spectrometry (ICP OES) method Germ.pdf
  • DIN EN 16139-2014 Furniture - Strength durability and safety - Requirements for non-domestic seating German version EN 16139 2013 + AC 2013《家具 强度耐用性和安全 非家用座椅的要求 德文版本EN 16139-2013+A.pdf DIN EN 16139-2014 Furniture - Strength durability and safety - Requirements for non-domestic seating German version EN 16139 2013 + AC 2013《家具 强度耐用性和安全 非家用座椅的要求 德文版本EN 16139-2013+A.pdf
  • DIN EN 16140-2011 Natural stone test methods - Determination of sensitivity to changes in appearance produced by thermal cycles German version EN 16140 2011《天然石试验方法 热循环导致的外表变化的敏感性测.pdf DIN EN 16140-2011 Natural stone test methods - Determination of sensitivity to changes in appearance produced by thermal cycles German version EN 16140 2011《天然石试验方法 热循环导致的外表变化的敏感性测.pdf
  • DIN EN 16141-2013 Conservation of cultural heritage Guidelines for management of environmental conditions Open storage facilities definitions and characteristics of collection cent.pdf DIN EN 16141-2013 Conservation of cultural heritage Guidelines for management of environmental conditions Open storage facilities definitions and characteristics of collection cent.pdf
  • DIN EN 16143-2013 Petroleum products - Determination of content of Benzo(a)pyrene (BaP) and selected polycyclic aromatic hydrocarbons (PAH) in extender oils - Procedure using doubl.pdf DIN EN 16143-2013 Petroleum products - Determination of content of Benzo(a)pyrene (BaP) and selected polycyclic aromatic hydrocarbons (PAH) in extender oils - Procedure using doubl.pdf
  • 相关搜索

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

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