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

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

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

2、f(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(Re

3、adDat() printf(“数据文件 ENG98. IN不能打开 !n007“); return; encryChar(); WriteDat(); int ReadDat(void) FILE *fp; int i=0; unsigned char *p; if(fp=fopen(“ENG98.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; in

4、t i; fp= fopen(“ps98.dat“,“w“); for(i=0;i maxline;i+) printf(“%sn“,xxi); fprintf(fp,“%sn“,xxi); fclose(fp); 国家三级信息管理技术机试模拟试卷 103答案与解析 一、程序设计题 1 【正确答案】 void encryChar() int i; char *pr; for(i=0;i maxline;i+) pf=xxi; /*指针 pf指向该行第一个字符 */ while(*pf!=0) if(*pf*11%256)%2!=O | *pf*11%256 =32) /*如果计算后的值小于等于

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

展开阅读全文
相关资源
猜你喜欢
  • ASTM A733-2003 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头标准规范》.pdf ASTM A733-2003 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头标准规范》.pdf
  • ASTM A733-2003(2009)e1 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头的标准规范》.pdf ASTM A733-2003(2009)e1 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头的标准规范》.pdf
  • ASTM A733-2013 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头的标准规格》.pdf ASTM A733-2013 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《焊接及无缝碳素钢和奥氏体不锈钢管接头的标准规格》.pdf
  • ASTM A733-2015 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《无缝焊接碳钢和奥氏体不锈钢管道接头的标准规格》.pdf ASTM A733-2015 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《无缝焊接碳钢和奥氏体不锈钢管道接头的标准规格》.pdf
  • ASTM A733-2016 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《无缝焊接碳钢和奥氏体不锈钢管道接头的标准规格》.pdf ASTM A733-2016 Standard Specification for Welded and Seamless Carbon Steel and Austenitic Stainless Steel Pipe Nipples《无缝焊接碳钢和奥氏体不锈钢管道接头的标准规格》.pdf
  • ASTM A734 A734M-1987a(2003) Standard Specification for Pressure Vessel Plates Alloy Steel and High-Strength Low-Alloy Steel Quenched-and-Tempered.pdf ASTM A734 A734M-1987a(2003) Standard Specification for Pressure Vessel Plates Alloy Steel and High-Strength Low-Alloy Steel Quenched-and-Tempered.pdf
  • ASTM A734 A734M-1987a(2007) Standard Specification for Pressure Vessel Plates Alloy Steel and High-Strength Low-Alloy Steel Quenched-and-Tempered《经淬火和回火的合金钢与高强度低合金钢压力容器板的标准规范》.pdf ASTM A734 A734M-1987a(2007) Standard Specification for Pressure Vessel Plates Alloy Steel and High-Strength Low-Alloy Steel Quenched-and-Tempered《经淬火和回火的合金钢与高强度低合金钢压力容器板的标准规范》.pdf
  • ASTM A735 A735M-2003 Standard Specification for Pressure Vessel Plates Low-Carbon Manganese-Molybdenum-Columbium Alloy Steel for Moderate and Lower Temperature Service.pdf ASTM A735 A735M-2003 Standard Specification for Pressure Vessel Plates Low-Carbon Manganese-Molybdenum-Columbium Alloy Steel for Moderate and Lower Temperature Service.pdf
  • ASTM A735 A735M-2003(2007) Standard Specification for Pressure Vessel Plates Low-Carbon Manganese-Molybdenum-Columbium Alloy Steel for Moderate and Lower Temperature Service《中温和低温用.pdf ASTM A735 A735M-2003(2007) Standard Specification for Pressure Vessel Plates Low-Carbon Manganese-Molybdenum-Columbium Alloy Steel for Moderate and Lower Temperature Service《中温和低温用.pdf
  • 相关搜索

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

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