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

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

1、三级信息管理技术机试-154 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:把 s 字符串中所有的字符左移一个位置,串中的第一个字符移到最后。请编制函数chg(char*s)实现程序要求,最后调用函数 readwriteDat()把结果输出到 out63dat 文件中。例如:s 字符串中原有内容为 Mn,123xyZ,则调用该函数后,结果为 n,123xyZM。注意:部分源程序已给出。 请勿改动主函数 main()和输入输出函数 IeadwriteDAT()的内容。试题程序:#includeconio. h#includ

2、estdio, h#define N 81void readwriteDAT ( );void chg(char *s)main ( )char a N;clrscr ( );printf(“Enter a string :“);gets (a);printf(“The original string is :“);puts (a);chg (a);printf(“The string after modified :“);puts (a);readwriteDAT ( );void readwriteDAT ( )int i;char a N;unsigned char *p;FILE *r

3、f,*wf;rf=fopen ( “in63. dar“, “r“ );wf= fopen ( “out 63. dat“ , “w“ );for (i=0; i10; i+)fgets(a,80,rf);p=strchr (a, /n );if (p) *p=0;chg (a);fprintf (wf, “%s/n“ ,a);fclose (rf);fclose (wf);(分数:100.00)_三级信息管理技术机试-154 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.下列程序的功能是:把 s 字符串中所有的字符左移一个位置,串中的第一

4、个字符移到最后。请编制函数chg(char*s)实现程序要求,最后调用函数 readwriteDat()把结果输出到 out63dat 文件中。例如:s 字符串中原有内容为 Mn,123xyZ,则调用该函数后,结果为 n,123xyZM。注意:部分源程序已给出。 请勿改动主函数 main()和输入输出函数 IeadwriteDAT()的内容。试题程序:#includeconio. h#includestdio, h#define N 81void readwriteDAT ( );void chg(char *s)main ( )char a N;clrscr ( );printf(“Ente

5、r a string :“);gets (a);printf(“The original string is :“);puts (a);chg (a);printf(“The string after modified :“);puts (a);readwriteDAT ( );void readwriteDAT ( )int i;char a N;unsigned char *p;FILE *rf,*wf;rf=fopen ( “in63. dar“, “r“ );wf= fopen ( “out 63. dat“ , “w“ );for (i=0; i10; i+)fgets(a,80,r

6、f);p=strchr (a, /n );if (p) *p=0;chg (a);fprintf (wf, “%s/n“ ,a);fclose (rf);fclose (wf);(分数:100.00)_正确答案:(void chg(char *s)int i, strl;char ch;strl=strlen (s); /*求字符串的长度*/ch=*s; /*将第一个字符暂赋给 ch*/for (i=0; istrl-1; i+) /*将字符依次左移*/*(s+i)=*(s+i+l);* (s+strl-1)=ch; /*将第一个字符移到最后*/)解析:解析 本题考查的知识点如下:(1)数组中元素的移动。(2)指针的使用。我们可以使用一个循环实现数组中所有字符元素的左移。这里要注意的是第 1 个字符要移至最后 1 个字符处,所以首先要将第 1 个字符保存。在移动时,要从左到右依次移动,否则,左侧的字符会在移动前被其右侧的字符覆盖。在这里使用了指针,初始时,指针指向数组的第 1 个元素,随着地址的增加指针指向数组后面的元素。例如,若地址加 2,则指向数组的第 3 个元素。

展开阅读全文
相关资源
猜你喜欢
  • EN 1770-1998 en Products and Systems for the Protection and Repair of Concrete Structures - Test Methods - Determination of the Coefficient of Thermal Expansion《混凝土结构保护和修缮用产品及系统的试验.pdf EN 1770-1998 en Products and Systems for the Protection and Repair of Concrete Structures - Test Methods - Determination of the Coefficient of Thermal Expansion《混凝土结构保护和修缮用产品及系统的试验.pdf
  • EN 1771-2004 en Products and systems for the protection and repair of concrete structures Test methods Determination of injectability and splitting test《混凝土结构保护和修缮用产品及系统的试验方法 使用沙柱试.pdf EN 1771-2004 en Products and systems for the protection and repair of concrete structures Test methods Determination of injectability and splitting test《混凝土结构保护和修缮用产品及系统的试验方法 使用沙柱试.pdf
  • EN 1772-2000 en Surface Active Agents - Determination of Wetting Power by Immersion《表面活性剂 用浸渍法测定润湿力 ISO 8022-1990 修件件》.pdf EN 1772-2000 en Surface Active Agents - Determination of Wetting Power by Immersion《表面活性剂 用浸渍法测定润湿力 ISO 8022-1990 修件件》.pdf
  • EN 1774-1997 en Zinc and Zinc Alloys - Alloys for Foundry Purposes - Ingot and Liquid《锌和锌合金 铸造厂用合金 铸块和液体》.pdf EN 1774-1997 en Zinc and Zinc Alloys - Alloys for Foundry Purposes - Ingot and Liquid《锌和锌合金 铸造厂用合金 铸块和液体》.pdf
  • EN 1775-2007 en Gas supply - Gas pipework for buildings - Maximum operating pressure less than or equal to 5 bar - Functional recommendations《燃气供应 建筑物用燃气管道 最大工作压力不超过或等于5巴 功能推荐标准》.pdf EN 1775-2007 en Gas supply - Gas pipework for buildings - Maximum operating pressure less than or equal to 5 bar - Functional recommendations《燃气供应 建筑物用燃气管道 最大工作压力不超过或等于5巴 功能推荐标准》.pdf
  • EN 1776-1998 Gas Supply Systems - Natural Gas Measuring Stations - Functional Requirements (Ratified European Text)《燃气供应系统 天然气测量站 功能要求 欧洲批准文本》.pdf EN 1776-1998 Gas Supply Systems - Natural Gas Measuring Stations - Functional Requirements (Ratified European Text)《燃气供应系统 天然气测量站 功能要求 欧洲批准文本》.pdf
  • EN 1776-2015 en Gas infrastructure - Gas measuring systems - Functional requirements《天然气基础设施 气体测量系统 功能要求》.pdf EN 1776-2015 en Gas infrastructure - Gas measuring systems - Functional requirements《天然气基础设施 气体测量系统 功能要求》.pdf
  • EN 1777-2010 en Hydraulic platforms (HPs) for fire fighting and rescue services - Safety requirements and testing《液压平台(HPs)消防和救援服务 安全要求和测试》.pdf EN 1777-2010 en Hydraulic platforms (HPs) for fire fighting and rescue services - Safety requirements and testing《液压平台(HPs)消防和救援服务 安全要求和测试》.pdf
  • EN 1778-1999 en Characteristic Values for Welded Thermoplastics Constructions - Determination of Allowable Stresses and Moduli for Design of Thermoplastics Equipment《焊接热塑结构的特性值 热塑性.pdf EN 1778-1999 en Characteristic Values for Welded Thermoplastics Constructions - Determination of Allowable Stresses and Moduli for Design of Thermoplastics Equipment《焊接热塑结构的特性值 热塑性.pdf
  • 相关搜索

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

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