【计算机类职业资格】计算机三级(数据库技术)上机考试18及答案解析.doc

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

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

2、p)的值小于等于 32,则该字符不变,否则将 f(p)所对应的字符进行替代。 注意:部分源程序已给出,原始数据文件存放的格式是:每行的宽度均小于 80 个字符。 请勿改动主函数 main()、读函数ReadDat()和写函数 WriteDat()的内容。 试题程序: #include #include #include #include unsigned char xx5080; int maxline = 0; /* 文章的总行数 */ int ReadDat(void); void WriteDat(void); void encryptChar() main() clrscr(); i

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

4、Dat(void) FILE *fp; int i; fp = fopen(“PS9.DAT“, “w“); for(i = 0; i maxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:-1.00)_计算机三级(数据库技术)上机考试 18 答案解析(总分:-1.00,做题时间:90 分钟)1.函数 ReadDat() 的功能是实现从文件 ENG9.IN 中读取一篇英文文章,存入到字符串数组 xx 中。请编制函数 encryptChar(),按给定的替代关系对数组 xx 中的所有字符进行替代,仍存入

5、数组 xx 的对应的位置上,最后调用函数 WriteDat()把结果 xx 输出到文件 PS9.DAT 中。 替代关系:f(p)=p*11 mod 256(p 是数组 xx 中某一个字符的 ASCII 值,f(p)是计算后新字符的 ASCII 值),如果原字符的 ASCII 值是偶数或计算后 f(p)的值小于等于 32,则该字符不变,否则将 f(p)所对应的字符进行替代。 注意:部分源程序已给出,原始数据文件存放的格式是:每行的宽度均小于 80 个字符。 请勿改动主函数 main()、读函数ReadDat()和写函数 WriteDat()的内容。 试题程序: #include #include

6、 #include #include unsigned char xx5080; int maxline = 0; /* 文章的总行数 */ int ReadDat(void); void WriteDat(void); void encryptChar() main() clrscr(); if(ReadDat() printf(“数据文件 ENG9.IN 不能打开!n007“); return; encryptChar(); WriteDat(); int ReadDat(void) FILE *fp; int i= 0; unsigned char *p; if (fp = fopen(

7、ENG9.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(void) FILE *fp; int i; fp = fopen(“PS9.DAT“, “w“); for(i = 0; i maxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:-1.00)_正确答

8、案:(void encryptChar() int i; char *pf; for(i=0;i=32) ; /*如果原字符的 ASCII 值是偶数或计算后的值小于等于 32,则该字符不变*/ else *pf=*pf*11%256; /*否则将所对应的字符进行替代*/ pf+; /*指针 pf 指向下一个字符*/ )解析:本题主要考查用指针变量来控制字符数组,由于要对已有二维字符数组的所有元素逐个处理,因此,需要定义一个字符指针变量来控制原二维数组的各行。当前行如果确定下来,用指针的移动就可以依次扫描该行的所有字符元素,每得到一个字符就对它进行条件判断。根据题意,条件用“if(*pf%2=0 | *pf*11%256=32)“来实现,如果该字符不满足上述条件,就用一个新的字符来替代,新的字符是当前字符乘以 11 的结果再去与 256 求余数,处理完毕后,指针去取下一个字符。如果该字符满足所给条件,将不做任何操作,指针直接下移,去取下一个字符,对下一个字符进行处理。

展开阅读全文
相关资源
猜你喜欢
  • DIN 19657-1973 Protection of Watercourses Dikes and Coastal Dunes Guidelines《水道、堤坝和海边沙丘的保护 指南》.pdf DIN 19657-1973 Protection of Watercourses Dikes and Coastal Dunes Guidelines《水道、堤坝和海边沙丘的保护 指南》.pdf
  • DIN 19658-2-1994 Polyethylene (PE) coiling pipes and hoses for irrigation systems - Part 2 Hoses with fabric inlay rigid form dimensions and technical delivery conditions《灌溉系统用可卷绕聚.pdf DIN 19658-2-1994 Polyethylene (PE) coiling pipes and hoses for irrigation systems - Part 2 Hoses with fabric inlay rigid form dimensions and technical delivery conditions《灌溉系统用可卷绕聚.pdf
  • DIN 19658-3-2016 Polyethylene (PE) coiling pipes and hoses for use in irrigation systems - Hoses of nonrigid material with woven fabric inner layer - Part 3 Dimensions and technica.pdf DIN 19658-3-2016 Polyethylene (PE) coiling pipes and hoses for use in irrigation systems - Hoses of nonrigid material with woven fabric inner layer - Part 3 Dimensions and technica.pdf
  • DIN 19660-1991 Measures of landscape management in land and water engineering《土地和水利工程中园林管理措施》.pdf DIN 19660-1991 Measures of landscape management in land and water engineering《土地和水利工程中园林管理措施》.pdf
  • DIN 19661-1-1998 Hydraulic structures - Part 1 Crossing works culvert works and drain works《水工建筑结构 第1部分 交叉结构工程、涵洞工程和排水工程》.pdf DIN 19661-1-1998 Hydraulic structures - Part 1 Crossing works culvert works and drain works《水工建筑结构 第1部分 交叉结构工程、涵洞工程和排水工程》.pdf
  • DIN 19661-2-2000 Hydraulic structures - Guidelines - Part 2 River bottom protection structures drop structures chutes cascades sills《水工结构 指南 第2部分 河床保护结构 跌水构筑物、陡槽、梯流和潜坝》.pdf DIN 19661-2-2000 Hydraulic structures - Guidelines - Part 2 River bottom protection structures drop structures chutes cascades sills《水工结构 指南 第2部分 河床保护结构 跌水构筑物、陡槽、梯流和潜坝》.pdf
  • DIN 19662-2012 Soil quality - Field tests - Determination of soil penetration resistance by means of a hand held penetrometer《土质 现场试验 使用手持式穿透计测定土壤的穿透阻力》.pdf DIN 19662-2012 Soil quality - Field tests - Determination of soil penetration resistance by means of a hand held penetrometer《土质 现场试验 使用手持式穿透计测定土壤的穿透阻力》.pdf
  • DIN 19663-1985 Torrent control terms planning and construction《山洪控制 术语 计划和建造》.pdf DIN 19663-1985 Torrent control terms planning and construction《山洪控制 术语 计划和建造》.pdf
  • DIN 19666-2001 Drain pipes and percolation pipes - General requirements《排水管道和渗滤管道 一般要求》.pdf DIN 19666-2001 Drain pipes and percolation pipes - General requirements《排水管道和渗滤管道 一般要求》.pdf
  • 相关搜索

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

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