【计算机类职业资格】三级网络技术机试-113及答案解析.doc

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

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

2、中,最后调用写函数 WriteDat()把结果输出到文件 OUT46.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;PRO sellMAX;void ReadDat();void WriteDat();void

3、 SortDat()void main ()memset (sell, 0, sizeof (sell);ReadDat ();SortDat ();WriteDat ();void ReadDat ()FILE *fp;char str80,ch11;int i;fp=fopen (“IN46. 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+14, 4);ch4=0;sell i .dj=atoi

4、ch);memcpy (ch, str+18.5);ch5=0;sell Iii . sl=atoi (ch);selli .je=(long) selli .dj*selli .sl;fclose (fp);void WriteDat()FILE *fp;int i;fp=fopen (“OUT46.DAT “, “w“);for (i=0; i100; i+)fprintf(fp,“%s %s %4d %5d%101d/n“,selli .dm, selli .mc, selli .dj,sellii .si,selli .je);fclose (fp);(分数:100.00)_三级网络

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

6、用写函数 WriteDat()把结果输出到文件 OUT46.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;PRO sellMAX;void ReadDat();void WriteDat();void Sort

7、Dat()void main ()memset (sell, 0, sizeof (sell);ReadDat ();SortDat ();WriteDat ();void ReadDat ()FILE *fp;char str80,ch11;int i;fp=fopen (“IN46. 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+14, 4);ch4=0;sell i .dj=atoi (ch);

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

9、d 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 Iii;selli=sellj;sell j =xy;else if (selli .je=sellj .je) /*若金额相同*/if (strcmp (sell ii . dm, sell j . dm) 0) /*则按产品代码从大到小进行排列*/xy=sell i;selli=sellj;sell j =xy;)解析:解析本题考查的知识点如下:(1)结构体及结构数组的相关操作。(2)结构数组的排序。(3)字符型数组的比较。本题着重考查结构体变量的访问、赋值,包括结构体本身及结构体中各个成员的访问和赋值。根据题意要求,我们首先要按照金额对记录从大到小进行排列。若金额相同,则要比较产品代码。因为产品代码为字符型,所以不能使用简单的比较运算符进行比较。在这里,我们使用了字符串处理函数 strcmp(char *strll,char*strl2,unsignedintcouO对其进行比较。因为已定义了结构数组,就可以使用循环进行比较排序。排序采用前面介绍的“选择排序法”。

展开阅读全文
相关资源
猜你喜欢
  • JUS H Z1 175-1985 Testing of industrial waters Determination of total arsenic Spectrophotometric method with silver die- thyldithiocarbamate《工业用水的检测 总砷含量的测定 二乙基二硫代氨基甲酸银分光光度法》.pdf JUS H Z1 175-1985 Testing of industrial waters Determination of total arsenic Spectrophotometric method with silver die- thyldithiocarbamate《工业用水的检测 总砷含量的测定 二乙基二硫代氨基甲酸银分光光度法》.pdf
  • JUS H Z1 177-1985 Testing of industrial waters Determination ofantimony content Flame atomfc absorption method《工业用水的检测 锑含量的测定 火焰原子吸收法》.pdf JUS H Z1 177-1985 Testing of industrial waters Determination ofantimony content Flame atomfc absorption method《工业用水的检测 锑含量的测定 火焰原子吸收法》.pdf
  • JUS H Z1 178-1985 Testing of industrial vvaters Determination of total mercury content Specirophotometric method with diphenyl-tiocarbazone《工业用水的检测 总汞含量的测定 联苯-硫卡巴腙分光光度法》.pdf JUS H Z1 178-1985 Testing of industrial vvaters Determination of total mercury content Specirophotometric method with diphenyl-tiocarbazone《工业用水的检测 总汞含量的测定 联苯-硫卡巴腙分光光度法》.pdf
  • JUS H Z1 179-1985 Testing of industrial vvaters Determination of nickel content Spectrophotometric method with dime- thyl glyoxlme《工业用水的检测 镍含量的测定 丁二酮肟分光光度法》.pdf JUS H Z1 179-1985 Testing of industrial vvaters Determination of nickel content Spectrophotometric method with dime- thyl glyoxlme《工业用水的检测 镍含量的测定 丁二酮肟分光光度法》.pdf
  • JUS H Z1 180-1985 Testing of industrial vvaters Determination of nickel content Polarographic method《工业用水检测 镍含量的测定 极谱法》.pdf JUS H Z1 180-1985 Testing of industrial vvaters Determination of nickel content Polarographic method《工业用水检测 镍含量的测定 极谱法》.pdf
  • JUS H Z1 181-1985 Testing of industrial vvaters Determination of calcium and magnesium content  EDTA  titrimetric method《工业用水检测 钙和镁含量的测定  EDTA滴定法》.pdf JUS H Z1 181-1985 Testing of industrial vvaters Determination of calcium and magnesium content EDTA titrimetric method《工业用水检测 钙和镁含量的测定 EDTA滴定法》.pdf
  • JUS H Z1 190-1984 Tastfng of industriai waters Determination ofsulphideconttnt Colorimetric mathod with p-amino-N N-di- methylaniline《工业用水的检测 硫化物含量的测定 对氨基 N:N-二 甲基苯胺比色法》.pdf JUS H Z1 190-1984 Tastfng of industriai waters Determination ofsulphideconttnt Colorimetric mathod with p-amino-N N-di- methylaniline《工业用水的检测 硫化物含量的测定 对氨基 N:N-二 甲基苯胺比色法》.pdf
  • JUS H Z1 195-1987 Testing of industrial vvaters Determination of thorium content Spectrophotometric method 《工业用水检测 钍含量的测定 分光光度法》.pdf JUS H Z1 195-1987 Testing of industrial vvaters Determination of thorium content Spectrophotometric method 《工业用水检测 钍含量的测定 分光光度法》.pdf
  • JUS H Z1 196-1987 Testing of industrial vvaters Determination of beryllium content Atomic absorption method《工业用水 铍含量的测定 原子吸收法》.pdf JUS H Z1 196-1987 Testing of industrial vvaters Determination of beryllium content Atomic absorption method《工业用水 铍含量的测定 原子吸收法》.pdf
  • 相关搜索

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

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