[计算机类试卷]国家三级信息管理技术机试模拟试卷101及答案与解析.doc

上传人:dealItalian200 文档编号:494901 上传时间:2018-11-28 格式:DOC 页数:4 大小:27.50KB
下载 相关 举报
[计算机类试卷]国家三级信息管理技术机试模拟试卷101及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家三级信息管理技术机试模拟试卷101及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家三级信息管理技术机试模拟试卷101及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家三级信息管理技术机试模拟试卷101及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级信息管理技术机试模拟试卷 101及答案与解析 一、程序设计题 1 函数 ReadDat()的功能是实现从文件 ENG96.IN中读取一篇英文文章,存入到字符串数组 xx中。请编制函数 encryChar(),按给定的替代关系对数组 xx中所有字符进行替代,仍存入数组 xx的对应的位置上,最后调用函数 WriteDat()把结果 xx输出到文件 ps96.dat中。 替代关系: f(p)=p*11 mod 256(p是数组 xx中某一个字符的 ASCII值, f(p)是计算后新字符的 ASCII值 ),如果原字符是小写字 母或计算后 f(p)的值小于等于 32,则该字符不变,否则将 f(

2、p)所对应的字符进行替代。 注意:部分源程序已给出,原始数据文件的存放格式是每行的宽度均小于 80个字符。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序: #include conio.h #include stdio.h #include string.h #include ctype.h unsigned char xx5080; int maxline=0; int ReadDat(void); void WriteDat(void); void encryChar() void main() clrscr(); if(Read

3、Dat() printf(“数据文件 ENG96.IN不能打开 !n007“); return; encryChar(); WriteDat(); int ReadDat(void) FILE *fp; int i=0; unsigned char *p; if(fp=fopen(“ENG96.IN“,“r“)=NULL) return 1; while(fgets(xxi,80,fp)!=NULL) p=strchr(xxi,n); if(p) *p=0; i+; maxline=i; fclose(fp); return 0; void WriteDat() FILE *fp; int i

4、 fp= fopen(“ps96.dat“,“w“); for(i=0;i maxline;i+) printf(“%sn“,xxi); fprintf(fp,“%sn“,xxi); fclose(fp) 国家三级信息管理技术机试模拟试卷 101答案与解析 一、程序设计题 1 【正确答案】 void encryChar() int i; char *pf; for(i=0;i maxline;i+) pf=xxi; /*指针 pf指向该行第一个字符 */ while(*pf!=0) if(*pf =a /*则不做改变,指向下一个字符 */ continue; /*退出本次循环 */ /*如果

5、原字符是小写字母或计算后的值小于等于 32*/ *pf=*pf*11%256; /*否则用新字符取代原有字符 */ pf+ /*指向下一个字符 */ 【试题解析】 本题考查的知识点如下; (1)字符对应的 ASCII码。 (2)判断结构中多个条件的 “或 ”运算。 (3)退出一次循环。 (4)二维数组的访问。 本题中,将数据存放在一个二维数组中,可以定义一个指向数组每一行的指针。初始时,指针指向该行的第一个元素,随着地址增加,指针指向后面的元素。在C语言中,字符可参与任何整数运算。实际上,是字符的 ASCII码参与了运算。所以可以直接用字符代入 f(p)的关系式中求出替换字符。若原字符是小写字母或f(p)32,则该字符不变。只有当字符大于等于 a小于等于 2时,才是小写字母,所以这两个条件之间用 “与 ”运算。而字符是小写字母与 f(p)32两条件满足一个即可,所以这两个条件之间用 “或 ”运算。若字符不变,则可不必计算替换字符,使用 continue跳出本次循环,进入下一次循环的条件判断中。因为这里不是直接退出循环结构,所以不能使用 break语句。

展开阅读全文
相关资源
猜你喜欢
  • ANSI INCITS ISO IEC 7816-12-2005 Identification cards - Integrated circuit cards - Part 12 Cards with contacts - USB electrical interface and operating procedures.pdf ANSI INCITS ISO IEC 7816-12-2005 Identification cards - Integrated circuit cards - Part 12 Cards with contacts - USB electrical interface and operating procedures.pdf
  • ANSI INCITS ISO IEC 7816-13-2007 Identification cards - Integrated circuit cards - Part 13 Commands for application management in a multi-application environment.pdf ANSI INCITS ISO IEC 7816-13-2007 Identification cards - Integrated circuit cards - Part 13 Commands for application management in a multi-application environment.pdf
  • ANSI INCITS ISO IEC 7816-15-2004 Identification cards - Integrated circuit cards with contacts - Part 15 Cryptographic information application.pdf ANSI INCITS ISO IEC 7816-15-2004 Identification cards - Integrated circuit cards with contacts - Part 15 Cryptographic information application.pdf
  • ANSI INCITS ISO IEC 7816-15-2004 Identification cards - Integrated circuit cards with contacts - Part 15 Cryptographic information application《识别卡.带触点的集成电路卡..第15部分 密码信息应用》.pdf ANSI INCITS ISO IEC 7816-15-2004 Identification cards - Integrated circuit cards with contacts - Part 15 Cryptographic information application《识别卡.带触点的集成电路卡..第15部分 密码信息应用》.pdf
  • ANSI INCITS ISO IEC 7816-2-1999 Information technology Identification cards Integrated circuit(s) cards with contacts Part 2 Dimensions and location of the contacts.pdf ANSI INCITS ISO IEC 7816-2-1999 Information technology Identification cards Integrated circuit(s) cards with contacts Part 2 Dimensions and location of the contacts.pdf
  • ANSI INCITS ISO IEC 7816-3 AMD 1-2002 Information technology - Identification cards - Integrated circuit(s) cards with contacts - Part 3 Electronic signals and transmission protoco.pdf ANSI INCITS ISO IEC 7816-3 AMD 1-2002 Information technology - Identification cards - Integrated circuit(s) cards with contacts - Part 3 Electronic signals and transmission protoco.pdf
  • ANSI INCITS ISO IEC 7816-3-1997 Information technology - Identification cards - Integrated circuit(s) cards with contacts - Part 3 Electronic signals and transmission protocols.pdf ANSI INCITS ISO IEC 7816-3-1997 Information technology - Identification cards - Integrated circuit(s) cards with contacts - Part 3 Electronic signals and transmission protocols.pdf
  • ANSI INCITS ISO IEC 7816-4-2013 Identification cards - Integrated circuit cards - Part 4 Organization security and commands for interchange.pdf ANSI INCITS ISO IEC 7816-4-2013 Identification cards - Integrated circuit cards - Part 4 Organization security and commands for interchange.pdf
  • ANSI INCITS ISO IEC 7816-5-1994 Identification cards - Integrated circuit(s) cards with contacts - Part 5 Numbering system and registration procedure for application identifiers.pdf ANSI INCITS ISO IEC 7816-5-1994 Identification cards - Integrated circuit(s) cards with contacts - Part 5 Numbering system and registration procedure for application identifiers.pdf
  • 相关搜索

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

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