【计算机类职业资格】计算机三级数据库技术-144及答案解析.doc

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

1、计算机三级数据库技术-144 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 ENG.IN中读取一篇英文文章,存入到字符串数组 xx中。请编写函数encryChar(),按给定的替代关系对数组 xx中所有字符进行替换,替换后的字符仍存入数组 xx的对应的位置上,最后调用函数 WriteDat(),把结果 xx输出到文件 PS.DAT中。 替代关系:f(p)=p*11 mod 256(p 是数组 xx中某一个字符的 ASCII码值,f(p)是计算后新字符的 ASCII码值),如果计算后 f(p)的值小于

2、等于 32或其 ASCII码值是奇数,则该字符不变,否则,将 f(p)所对应的字符进行替换。 注意:原始数据文件的存放格式是每行的宽度均小于 80个字符。请勿改动主函数 main()、读函数ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdlib.h #include stdio.h #include string.h #include ctype.h unsigned char xx50 80 ; int maxline =0 ; int ReadDat (void) ; void WriteDat (void) ; void encryChar

3、 () void main () system (“CLS“) ; if (ReadDat () printf (“数据文件 ENG. IN 无法打开! n007“) ; return; encryChar () ; WriteDat () ; int ReadDat (void) FILE * fp; int i =0; unsigned char * p; if ( (fp = fopen (“ENG. IN“, “r“) ) =NULL) return 1 ; while (fgets (xxi ,80, fp) ! =NULL) p =strchr (xxi,“n“) ; if (p)

4、 * p=0; i+; maxl ine = i ; fclose (fp) ; return 0 ; void WriteDat() FILE * fp; int i; fp = fopen (“ps .dat“, “w“) ; for (i =0;i maxline;i +) printf(“%sn“,xxi); fprintf(fp,“%sn“,xxi); fclose(fp); (分数:100.00)_计算机三级数据库技术-144 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 ReadDat()的功能是从文件 ENG.IN中读

5、取一篇英文文章,存入到字符串数组 xx中。请编写函数encryChar(),按给定的替代关系对数组 xx中所有字符进行替换,替换后的字符仍存入数组 xx的对应的位置上,最后调用函数 WriteDat(),把结果 xx输出到文件 PS.DAT中。 替代关系:f(p)=p*11 mod 256(p 是数组 xx中某一个字符的 ASCII码值,f(p)是计算后新字符的 ASCII码值),如果计算后 f(p)的值小于等于 32或其 ASCII码值是奇数,则该字符不变,否则,将 f(p)所对应的字符进行替换。 注意:原始数据文件的存放格式是每行的宽度均小于 80个字符。请勿改动主函数 main()、读函

6、数ReadDat()和写函数 WriteDat()的内容。 【试题程序】 #include stdlib.h #include stdio.h #include string.h #include ctype.h unsigned char xx50 80 ; int maxline =0 ; int ReadDat (void) ; void WriteDat (void) ; void encryChar () void main () system (“CLS“) ; if (ReadDat () printf (“数据文件 ENG. IN 无法打开! n007“) ; return;

7、encryChar () ; WriteDat () ; int ReadDat (void) FILE * fp; int i =0; unsigned char * p; if ( (fp = fopen (“ENG. IN“, “r“) ) =NULL) return 1 ; while (fgets (xxi ,80, fp) ! =NULL) p =strchr (xxi,“n“) ; if (p) * p=0; i+; maxl ine = i ; fclose (fp) ; return 0 ; void WriteDat() FILE * fp; int i; fp = fop

8、en (“ps .dat“, “w“) ; for (i =0;i maxline;i +) printf(“%sn“,xxi); fprintf(fp,“%sn“,xxi); fclose(fp); (分数:100.00)_正确答案:()解析:void encryChar() int i,j; /*定义循环控制变量*/ int str; /*存储字符串的长度*/ char ch; /*存储当前取得的字符*/ for(i=0;imaxline;i+) /*以行为单位获取字符*/ str=strlen(xxi); /*求得当前行的字符串长度*/ for(j=0;jstr;j+) /*依次取每行的

9、所有字符*/ ch=xxij*11%256; if(ch=32 | ch%2!=0) /*如果计算后的值小于等于 32或其 ASCII值是奇数*/ continue; /*则不做改变,指向下一个字符*/ xxij=ch; /*否则用新字符取代原有字符*/ 考点 本题考查对多个整数的筛选以及求平均值。考查的知识点主要包括:多位整数的分解算法,逻辑表达式,平均值的计算方法。 解析 本题属于字符串类题。首先用 strlen()函数得到当前行所包含的字符个数。 然后再利用一个循环来依次访问该行中的所有字符。对于每一个字符,先按照题目中的函数替代关系“f(p)=p*11 mod 256“计算出相应的 fp值,再用一条 if语句判断该值是否符合本题给定的条件:“计算后的值小于等于 32或为奇数“。如果符合条件,则该字符不变,否则用 f(p)所对应的字符对其进行替代。 分解 4位数时算术运算符的使用,if 判断语句中的逻辑表达式。

展开阅读全文
相关资源
猜你喜欢
  • KS I ISO 11423-1-2008 Water quality-Determination of benzene and some derivatives-Part 1:Head-space gas chromatographic method《水质 苯及其衍生物的测定 第1部分 顶空气相色谱法》.pdf KS I ISO 11423-1-2008 Water quality-Determination of benzene and some derivatives-Part 1:Head-space gas chromatographic method《水质 苯及其衍生物的测定 第1部分 顶空气相色谱法》.pdf
  • KS I ISO 11423-2-2008 Water quality-Determination of benzene and some derivatives-Part 2:Method using extraction and gas chromatography《水质 苯及其衍生物的测定 第2部分 萃取气相色谱法》.pdf KS I ISO 11423-2-2008 Water quality-Determination of benzene and some derivatives-Part 2:Method using extraction and gas chromatography《水质 苯及其衍生物的测定 第2部分 萃取气相色谱法》.pdf
  • KS I ISO 11464-2007 Soil quality-Pretreatment of samples for physico-chemical analysis《土壤质量 物理化学分析用样品的预处理》.pdf KS I ISO 11464-2007 Soil quality-Pretreatment of samples for physico-chemical analysis《土壤质量 物理化学分析用样品的预处理》.pdf
  • KS I ISO 11465-2005 Soil quality-Determination of dry matter and water contenton a mass basis-Gravimetric method《土壤质量 土壤生物的干物质和水含量的测定 重量法》.pdf KS I ISO 11465-2005 Soil quality-Determination of dry matter and water contenton a mass basis-Gravimetric method《土壤质量 土壤生物的干物质和水含量的测定 重量法》.pdf
  • KS I ISO 11466-2008 Soil quality-Extraction of trace elements soluble in aqua regia《土壤质量 溶解于王水中的痕量元素的提取》.pdf KS I ISO 11466-2008 Soil quality-Extraction of trace elements soluble in aqua regia《土壤质量 溶解于王水中的痕量元素的提取》.pdf
  • KS I ISO 11508-2009 Soil quality-Determination of particle density《土壤质量 粒子密度的测定》.pdf KS I ISO 11508-2009 Soil quality-Determination of particle density《土壤质量 粒子密度的测定》.pdf
  • KS I ISO 11541-2008 Natural gas-Determination of water content at high pressure《天然气 高压下含水量的测定》.pdf KS I ISO 11541-2008 Natural gas-Determination of water content at high pressure《天然气 高压下含水量的测定》.pdf
  • KS I ISO 11732-2008 Water quality-Determination of ammonium nitrogen-Method by flow analysis(CFA and FIA) and spectrometric detection《水质 氨氮的测定 流动分析(CFA和FIA)法和光谱测定法》.pdf KS I ISO 11732-2008 Water quality-Determination of ammonium nitrogen-Method by flow analysis(CFA and FIA) and spectrometric detection《水质 氨氮的测定 流动分析(CFA和FIA)法和光谱测定法》.pdf
  • KS I ISO 11733-2008 Water quality-Determination of the elimination and biodegradability of organic compounds in an aqueous medium-Activated sludge simulation test《水质 水介质中有机化合物的生物降解.pdf KS I ISO 11733-2008 Water quality-Determination of the elimination and biodegradability of organic compounds in an aqueous medium-Activated sludge simulation test《水质 水介质中有机化合物的生物降解.pdf
  • 相关搜索

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

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