【计算机类职业资格】三级信息管理技术机试-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 个元素。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO IEC 29142-1-2013 Information technology Print cartridge characterization General terms symbols notations and cartridge characterization framework《信息技术 打印盒特性描述 总论 术语、符号、标记和墨盒.pdf BS ISO IEC 29142-1-2013 Information technology Print cartridge characterization General terms symbols notations and cartridge characterization framework《信息技术 打印盒特性描述 总论 术语、符号、标记和墨盒.pdf
  • BS ISO IEC 29143-2011 Information technology Automatic identification and data capture techniques Air interface specification for mobile RFID interrogators《信息技术 自动识别与数据采集技术 移动RFID问.pdf BS ISO IEC 29143-2011 Information technology Automatic identification and data capture techniques Air interface specification for mobile RFID interrogators《信息技术 自动识别与数据采集技术 移动RFID问.pdf
  • BS ISO IEC 29147-2014 Information technology Security techniques Vulnerability disclosure《信息技术 安全技术 漏洞公告》.pdf BS ISO IEC 29147-2014 Information technology Security techniques Vulnerability disclosure《信息技术 安全技术 漏洞公告》.pdf
  • BS ISO IEC 29155-2-2013 Systems and software engineering Information technology project performance benchmarking framework Requirements for benchmarking《信息和软件工程 信息技术项目绩效杠杆分析法框架 杠杆分.pdf BS ISO IEC 29155-2-2013 Systems and software engineering Information technology project performance benchmarking framework Requirements for benchmarking《信息和软件工程 信息技术项目绩效杠杆分析法框架 杠杆分.pdf
  • BS ISO IEC 29155-4-2016 Systems and software engineering Information technology project performance benchmarking framework Guidance for data collection and maintenance《系统和软件工程 信息技术.pdf BS ISO IEC 29155-4-2016 Systems and software engineering Information technology project performance benchmarking framework Guidance for data collection and maintenance《系统和软件工程 信息技术.pdf
  • BS ISO IEC 29167-1-2012 Information technology Automatic identification and data capture techniques Air interface for security services and file management for RFID architecture《信息.pdf BS ISO IEC 29167-1-2012 Information technology Automatic identification and data capture techniques Air interface for security services and file management for RFID architecture《信息.pdf
  • BS ISO IEC 29169-2016 Information technology Process assessment Application of conformity assessment methodology to the assessment to process quality characteristics and organizati.pdf BS ISO IEC 29169-2016 Information technology Process assessment Application of conformity assessment methodology to the assessment to process quality characteristics and organizati.pdf
  • BS ISO IEC 29173-1-2012 Information technology Mobile item identification and management Mobile RFID interrogator device protocol for ISO IEC 18000-63 Type C《信息技术 移动项目识别和管理 用于ISO I.pdf BS ISO IEC 29173-1-2012 Information technology Mobile item identification and management Mobile RFID interrogator device protocol for ISO IEC 18000-63 Type C《信息技术 移动项目识别和管理 用于ISO I.pdf
  • BS ISO IEC 29176-2011 Information technology Mobile item identification and management Consumer privacy-protection protocol for Mobile RFID services《信息技术 手机产品识别和管理 手机RFID服务的消费者隐私保护.pdf BS ISO IEC 29176-2011 Information technology Mobile item identification and management Consumer privacy-protection protocol for Mobile RFID services《信息技术 手机产品识别和管理 手机RFID服务的消费者隐私保护.pdf
  • 相关搜索

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

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