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

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

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

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

3、 WriteDat();void SortDat()void main()memset(sell,0,sizeof(sell);ReadDat();SorrDat();WriteDat();void ReadDat()FILE *fp;char str80,ch11;int i;fp=fopen(“IN6.DAT“,“r“);for(i=0;i100;i+)fgets(str,80,fp);memcpy(selli.dm,str,4);memcpy(selli.mc,str+4,10);memcpy(ch,str+14,4);ch4=0;selli.dj=atoi(ch);memcpy(ch,

4、str+18,5);ch5=0;selli.s1=atoi(ch);selli.je=(long)selli.dj*selli.s1;fclose(fp);void WriteDat(void)FILE *fp;int i;fp=fopen(“OUT6.DAT“,“w“);for(i=0;i100;i+)fprintf(fp,“%s%s%4d%5d%101d/n“,selli.dm,selli.mc,selli.dj,selli.s1,selli.je);fclose(fp);(分数:100.00)_三级信息管理技术机试-230 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(

5、总题数:1,分数:100.00)1.已知在文件 IN6.DAT 中存有 100 个产品销售记录,每个产品销售记录由产品代码 dm(字符型 4 位)、产品名称 mc(字符型 10 位)、单价 dj(整型)、数量 s1(整型)、金额 je(长整型)五部分组成。其中:金额单价数量。函数 ReadDat()的功能是读取这 100 个销售记录并存入结构数组 sell 中。请编制函数SortDat(),其功能要求:按产品代码从小到大进行排列,若产品代码相同,则按金额从小到大进行排列,最终排列结果仍存入结构数组 sell 中,最后调用函数 WriteDat()把结果输出到文件 OUT6.DAT 中。注意:部

6、分源程序已给出。请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。试题程序#include #Include #include #include #include #define MAX 100typedef structchar dm5 /*产品代码*/char mc11; /*产品名称*/int dj; /*单价*/int s1; /*数量*/long je; /*金额*/PRO;PRO sellMAX;void ReadDat();void WriteDat();void SortDat()void main()memset(sell

7、0,sizeof(sell);ReadDat();SorrDat();WriteDat();void ReadDat()FILE *fp;char str80,ch11;int i;fp=fopen(“IN6.DAT“,“r“);for(i=0;i100;i+)fgets(str,80,fp);memcpy(selli.dm,str,4);memcpy(selli.mc,str+4,10);memcpy(ch,str+14,4);ch4=0;selli.dj=atoi(ch);memcpy(ch,str+18,5);ch5=0;selli.s1=atoi(ch);selli.je=(long

8、)selli.dj*selli.s1;fclose(fp);void WriteDat(void)FILE *fp;int i;fp=fopen(“OUT6.DAT“,“w“);for(i=0;i100;i+)fprintf(fp,“%s%s%4d%5d%101d/n“,selli.dm,selli.mc,selli.dj,selli.s1,selli.je);fclose(fp);(分数:100.00)_正确答案:(void SortDat()int i,j;PRO xy;for(i=0;iMAX-1;i+)for(j=i+1;jMAX;j+)if(strcmp(selli.dm,sellj

9、dm)0) /*按代码从小到大进行排列*/ xy=selli;selli=sellj;sellj=xy;else if(strcmp(selli.dm,sellj.dm)=0) /*若代码相同*/if(selli.jesellj.je) /*则按金额从小到大进行排列*/ xy=selli;selli=sellj;sellj=xy;)解析:解析 此题型考查的知识点包括以下几方面:(1)结构体数组的排序;(2)结构体及结构体数组的相关操作;(3)字符型数组的比较;(4)C 语言库函数的使用(如函数 strcmp()。此题按产品代码从小到大进行排列,若产品代码相同,则按金额从小到大进行排列,相应语句为:if(strcmp(selli.dm,sellj.dm)0)|(strcmp(selli.dm,sellj.dm)=0)&(selli.jesellj.je)

展开阅读全文
相关资源
猜你喜欢
  • DIN ISO 7905-2-1998 Plain bearings - Bearing fatigue - Part 2 Test with a cylindrical specimen of a metallic bearing material (ISO 7905-2 1996)《关节轴承 轴承疲劳强度 第2部分 用金属轴承材料圆柱形试样作试验》.pdf DIN ISO 7905-2-1998 Plain bearings - Bearing fatigue - Part 2 Test with a cylindrical specimen of a metallic bearing material (ISO 7905-2 1996)《关节轴承 轴承疲劳强度 第2部分 用金属轴承材料圆柱形试样作试验》.pdf
  • DIN ISO 7905-3-1998 Plain bearings - Bearing fatigue - Part 3 Tests on plain strips of a metallic multilayer bearing material (ISO 7905-3 1996)《关节轴承 轴承疲劳强度 第3部分 金属复合层轴承材料普通带材的试验》.pdf DIN ISO 7905-3-1998 Plain bearings - Bearing fatigue - Part 3 Tests on plain strips of a metallic multilayer bearing material (ISO 7905-3 1996)《关节轴承 轴承疲劳强度 第3部分 金属复合层轴承材料普通带材的试验》.pdf
  • DIN ISO 7905-4-1998 Plain bearings - Bearing fatigue - Part 4 Test on half-bearings of a metallic multilayer bearing material (ISO 7905-4 1996)《关节轴承 轴承疲劳强度 第4部分 金属复合层轴承材料的轴承品的试验》.pdf DIN ISO 7905-4-1998 Plain bearings - Bearing fatigue - Part 4 Test on half-bearings of a metallic multilayer bearing material (ISO 7905-4 1996)《关节轴承 轴承疲劳强度 第4部分 金属复合层轴承材料的轴承品的试验》.pdf
  • DIN ISO 7913-1986 Aerospace fasteners tolerances of form and position for bolts and screws identical with ISO 7913 edition 1985《航空和航天 紧固件 螺栓和螺钉的形状和位置公差 等同采用 ISO 7913-1986》.pdf DIN ISO 7913-1986 Aerospace fasteners tolerances of form and position for bolts and screws identical with ISO 7913 edition 1985《航空和航天 紧固件 螺栓和螺钉的形状和位置公差 等同采用 ISO 7913-1986》.pdf
  • DIN ISO 7919-5-2005 Mechanical vibration - Evaluation of machine vibration by measurements on rotating shafts - Part 5 Machine sets in hydraulic power generating and pumping plants.pdf DIN ISO 7919-5-2005 Mechanical vibration - Evaluation of machine vibration by measurements on rotating shafts - Part 5 Machine sets in hydraulic power generating and pumping plants.pdf
  • DIN ISO 7931-1989 Insulation caps and bushes for resistance welding equipment identical with ISO 7931 1985《电阻焊设备的绝缘帽和套》.pdf DIN ISO 7931-1989 Insulation caps and bushes for resistance welding equipment identical with ISO 7931 1985《电阻焊设备的绝缘帽和套》.pdf
  • DIN ISO 7975-1987 Road vehicles braking in a turn open loop test procedure identical with ISO 7975 edition 1985《道路车辆 转圈制动 开环试验程序》.pdf DIN ISO 7975-1987 Road vehicles braking in a turn open loop test procedure identical with ISO 7975 edition 1985《道路车辆 转圈制动 开环试验程序》.pdf
  • DIN ISO 7991-1998 Glass - Determination of coefficient of mean linear thermal expansion (ISO 7991 1987)《玻璃 热平均线性膨胀系数的测定》.pdf DIN ISO 7991-1998 Glass - Determination of coefficient of mean linear thermal expansion (ISO 7991 1987)《玻璃 热平均线性膨胀系数的测定》.pdf
  • DIN ISO 8002-1995 Mechanical vibrations - Land vehicles - Method for reporting measured data identical with ISO 8002 1986《机械振动 地面车辆 报告测量数据的方法 等同采用 ISO 8002 1986》.pdf DIN ISO 8002-1995 Mechanical vibrations - Land vehicles - Method for reporting measured data identical with ISO 8002 1986《机械振动 地面车辆 报告测量数据的方法 等同采用 ISO 8002 1986》.pdf
  • 相关搜索

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

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